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: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to