You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2002/05/10 13:44:13 UTC
DO NOT REPLY [Bug 8974] New: -
Serialized version of valid xml document is invalid.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8974>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8974
Serialized version of valid xml document is invalid.
Summary: Serialized version of valid xml document is invalid.
Product: Xerces2-J
Version: 2.0.0
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: Serialization
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: jitendra.shah@db.com
I have document:
<?xml version="1.0" encoding="UTF-8"?>
<BOOK
xmlns="http://rpl.risk.db.com/rplweb/dbNexus"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://rpl.risk.db.com/rplweb/dbNexus
http://rpl.risk.db.com/rplweb/dbNexus/book.xsd"
>
<BOOK_ID>0</BOOK_ID>
<BOOK_NAME>BB_AA_RES_DIR</BOOK_NAME>
<BOOK_DESC> BB_AA_RES_DIR</BOOK_DESC>
<INDEX> Req. by T.B. on 16.7.01</INDEX>
</BOOK>
I parse this into a DOM with xml schema
validation turned on.
I serialize the document using OutputFormat.
I get :
<?xml
version="1.0" encoding="UTF-8"?>
<BOOK
xmlns="http://rpl.risk.db.com/rplweb/dbNexus"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://rpl.risk.db.com/rplweb/dbNexus
http://rpl.risk.db.com/rplweb/dbNexus/book.xsd">
<BOOK_ID>0</BOOK_ID>
<BOOK_NAME>BB_AA_RES_DIR</BOOK_NAME>
<BOOK_DESC> BB_AA_RES_DIR</BOOK_DESC>
<INDEX> Req. by T.B. on 16.7.01</INDEX>
</BOOK>
Note that the "xmlns:xsi" attribute is
repeated. This resulting document is no longer valid.
Code:
DocumentBuilderFactory
dbf = DocumentBuilderFactory.newInstance();
// set up schema validation
dbf.setValidating(true);
dbf.setNamespaceAware(true);
dbf.setAttribute("http://xml.org/sax/features/validation", new Boolean(true));
dbf.setAttribute("http://apache.org/xml/features/validation/dynamic", new
Boolean(true));
dbf.setAttribute("http://apache.org/xml/features/validation/schema", new
Boolean(true));
DocumentBuilder db = dbf.newDocumentBuilder();
db.setErrorHandler(this);
Document doc = db.parse(xmlURL);
OutputFormat format = new
OutputFormat(); //Serialize DOM
format.setIndenting(true);
format.setLineSeparator("\n");
format.setIndent(4);
StringWriter stringOut = new
StringWriter(); //Writer will be a String
XMLSerializer serial = new XMLSerializer(
stringOut, format );
serial.serialize(doc);
System.out.println( "STRXML = " +
stringOut.toString() );
xmlStr = stringOut.toString();
Many Thanks,
Jitendra
Shah
jitendra.shah@db.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org