Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] How to add a xmlns:prefix attribute to an element

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Michael Kay <mike AT saxonica.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] How to add a xmlns:prefix attribute to an element
  • Date: Wed, 11 Aug 2010 09:23:56 +0100

Have you tried

Element.addNamespaceDeclaration("custom", "http://example.com/opensearchextensions/1.0/";);

Michael Kay
Saxonica


On 11/08/2010 07:49, Imran M Yousuf wrote:
Hi,

I am facing a little problem :).
http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_Query_element
I am trying to implement a DOM serialization and deserialization api
for this specification. A part of is to be able to write -
<Query xmlns:custom="http://example.com/opensearchextensions/1.0/";
role="custom:example"
searchTerms="cat"
title="Sample search" />
The problem is I can not add xmlns:* attributes as it rightly
identifies it as NS and throws an exception. But if I do provide an
URI for the role attribute that would behave wrongly as it will make
'role' under that NS with empty prefix. One way I am currently
employing to get around it is to use another dummy attribute, such as
custom:add="val" with the custom's NS, then it adds the xmlns
automatically. But I would not want to do it always.

Can you please suggest me how I could achieve just achieving the following?
<Query xmlns:custom="http://example.com/opensearchextensions/1.0/";
role="custom:example"
searchTerms="cat"
title="Sample search" />

Thank you,






Archive powered by MHonArc 2.6.24.

Top of Page