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=16103>.
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=16103

Serialization of namespace-prefixes attributes does not create appropriate namespace 
declaration

           Summary: Serialization of namespace-prefixes attributes does not
                    create appropriate namespace declaration
           Product: Xerces2-J
           Version: 2.2.1
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Serialization
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Namespace declarations are not being serialized when using setAttributeNS.  
In the case 
where the namespace prefix is supplied, the XML serialization does not add a 
"xmlns:<prefix>" 
attribute.
In the case where the namespace prefix is not supplied, the serialization uses 
"null:" as the prefix, and there is no "xmlns:null" attribute.
I feel that the serialization is 
incorrect - please can someone investigate.

For this xml document:
<?xml version="1.0" 
encoding="UTF-8"?>
<DBNTEST1
    xmlns="http://dbnexus.risk.db.com/schema/DBNTEST1"; 
docVersion="3" documentID="351339" enddate="4999-12-31T00:00:00.000" 
isCurrentVersion="true" isEditable="true" startdate="2002-12-10T12:19:38.782" 
uniqueID="351361"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    
xsi:schemaLocation="http://dbnexus.risk.db.com/schema/DBNTEST1 
http://dbnexus.risk.db.com/schema/DBNTEST1_V6.xsd";>
    <TEST_ID>8</TEST_ID>
    
<TEST_DESC>NEW ONEA</TEST_DESC>
    <BRANCH_CODE_TEST_REF>
        <reference 
href="http://dbnexus.risk.db.com/schema/BRANCH_CODE_TEST?/BRANCH_CODE_TEST/@documentID=340775";
 
type="simple"/>
    </BRANCH_CODE_TEST_REF>
    
<DEC_TEST>11</DEC_TEST>
</DBNTEST1>

I am doing this:

        DocumentBuilderFactory dbf 
= xmlHelper.getNonValidatingDBF();
        dbf.setNamespaceAware(true);
        DocumentBuilder db 
= dbf.newDocumentBuilder();

        Document doc = db.parse( new InputSource( new StringReader( 
xmlstring) ) );
        doc.getDocumentElement().setAttributeNS( 
"http://www.w3.org/2001/XMLSchema-instance";,
                "newxsi:schemaLocation", 
"http://dbnexus.risk.db.com/schema/DBNTEST1 
http://dbnexus.risk.db.com/schema/DBNTEST1_V999.xsd"; );


        OutputFormat of = new 
OutputFormat();
        of.setIndenting( true );
        of.setIndent( 4 );
        of.setLineSeparator( 
"\n" );
        of.setLineWidth( 0 );
        XMLSerializer xs = new XMLSerializer( of );
        StringWriter sw 
= new StringWriter();
        xs.setOutputCharStream( sw );
        xs.serialize( document );
        String 
moddoc = sw.toString();

        System.out.println( "serialized modified doc:" + moddoc );        

        
Document mdoc = db.parse( new InputSource( new StringReader( moddoc )        );

The xml document 
generated by the serialization is :

<?xml version="1.0" encoding="UTF-8"?>
<DBNTEST1 
docVersion="3" documentID="351339" enddate="4999-12-31T00:00:00.000" 
isCurrentVersion="true" isEditable="true" startdate="2002-12-10T12:19:38.782" 
uniqueID="351361" xmlns="http://dbnexus.risk.db.com/schema/DBNTEST1"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
newxsi:schemaLocation="http://dbnexus.risk.db.com/schema/DBNTEST1 
http://dbnexus.risk.db.com/schema/DBNTEST1_V999.xsd";>
    <TEST_ID>8</TEST_ID>
    
<TEST_DESC>NEW ONEA</TEST_DESC>
    <BRANCH_CODE_TEST_REF>
        <reference 
href="http://dbnexus.risk.db.com/schema/BRANCH_CODE_TEST?/BRANCH_CODE_TEST/@documentID=340775";
 
type="simple"/>
    </BRANCH_CODE_TEST_REF>
    
<DEC_TEST>11</DEC_TEST>
</DBNTEST1>


The namespace declaration:
     
xmlns:newxsi="http://dbnexus.risk.db.com/schema/DBNTEST1"; 
... is missing in the 
serialized document.

We have recently upgraded from Xerces2.0.1 to Xerces2.2.1 - 
Xerces2.0.1 added the namespace declaration for us.

As a workaround, we are adding the 
namespace declaration to the xml document in code.

Many Thanks,
Jitendra

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

Reply via email to