You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Brad Taylor <Br...@TELUS.COM> on 2004/10/08 19:41:34 UTC
removing default namespace
I am using XMLbeans to model a DocBook XML document.
I have had to add a default namespace to the document in order to access nodes using the XMLCursor interface and the selectPath() method.
Downstream processing requires that the default namespace be removed - DocBook XML grammar does not include any namespaces and including them means that the downstream processors do not recognize the XML as DocBook grammar.
How do I:
1. remove the default namespace?
or
2. configure the XMLbean generation/XMLCursor to not require a namespace?
The code I'm using looks like this:
ArticleDocument newArticleDoc = getTier2Template();
XmlCursor cursor = newArticleDoc.newCursor();
final String DEFAULT_NAMESPACE = "http://oasis-open.org/docbook/xml";
String namespace = "declare namespace test='"+DEFAULT_NAMESPACE+"' ";
String xpath = "$this//test:subjectterm[@id='articleSubject']";
try{
cursor.push(); //save top position
if (! cursor.toFirstChild())
throw new Exception("cursor.toFirstChild() failed");
cursor.selectPath(xpath);
if (cursor.hasNextSelection()){
if (cursor.toNextSelection()) {
cursor.setTextValue(newValue);
returnValue=1;
while (replaceAll && cursor.toNextSelection()){
cursor.setTextValue("some changed value");
returnValue += 1;
}
}
} else{
//xPath not found
returnValue = 0;
}
} finally{
//cursor.pop();
if (cursor != null){
cursor.dispose();
}
}
The document looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<article xmlns="http://oasis-open.org/docbook/xml">
<title id="articleTitle">Application Support Document</title>
<articleinfo>
<subjectset>
I want the top level element to be:
<article>
not
<article xmlns="http://oasis-open.org/docbook/xml">
thanks,
Brad
--
Brad Taylor, TELUS Technology & Operations ITI Operations
Floor 2 TELUS Internet Data Centre, 1525 10 Ave SW, Calgary AB T3C 0J6
phone 403 503-3023; mobile 403 852-6067; email <ma...@telus.com> brad.taylor@telus.com