You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by sa...@ca.ibm.com on 2002/02/22 21:39:38 UTC

Re: [Fwd: RE: XMLSerializer problem]

Hi Cirip,

After struggling for more than an hour, Elena and I finally found the cause
of the problem. And it turned out to be a very interesting one: it doesn't
occur on JDK 1.2.2, and does occur on JDK 1.3 when the program is debugged.

Anyway, Elena will put down the fix soon, and hopefully when you download
the new jar files next week (or tomorrow), you'll see the fix.

Cheers,
Sandy Gao
Software Developer, IBM Canada
(1-905) 413-3255
sandygao@ca.ibm.com

-------- Original Message --------
Subject: RE: XMLSerializer problem
Date: Thu, 21 Feb 2002 14:20:46 -0500
From: Cirip Tomas <to...@theIMO.com>
Reply-To: xerces-j-user@xml.apache.org
To: "'xerces-j-user@xml.apache.org'" <xe...@xml.apache.org>

Elena,

I've downloaded lates jars (Feb 21, 2002) and still have the same
problem.
Find attached XML document, schema file, java code and result. I noticed
there is a bug posted in Bugzilla - Thank you

{
      DOMParser parser = new DOMParser();
      parser.parse("file:///d:\\tc\\xmlparadise\\xml\\test_schema.xml");
      Document doc = parser.getDocument();

      OutputFormat outputFormat = new OutputFormat(doc);
      outputFormat.setIndenting(true);

      XMLSerializer serializer = new XMLSerializer(System.out,
outputFormat);
      serializer.serialize(doc);
}

--------------------------------------------------
XML File:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="D:\tc\xmlparadise\xml\test.xsd">
     <node1 attr1="cvirko">
          <node11/>
          <node12/>
     </node1>
     <node2>
          <node21/>
          <node22/>
     </node2>
</root>

--------------------------------------------------
Result is

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="D:\tc\xmlparadise\xml\test.xsd">
    <node1 attr1="cvirko">
        <node11/>
        <node12/>
    </node1>
    <node2>
        <node21/>
        <node22/>
    </node2>
</root>

--------------------------------------------------
XML Schema file is

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
     <xs:element name="root">
          <xs:complexType>
               <xs:sequence>
                    <xs:element name="node1">
                         <xs:complexType>
                              <xs:sequence>
                                   <xs:element
name="node11"/>
                                   <xs:element
name="node12"/>
                              </xs:sequence>
                              <xs:attribute name="attr1"
type="xs:string" use="optional"/>
                         </xs:complexType>
                    </xs:element>
                    <xs:element name="node2">
                         <xs:complexType>
                              <xs:sequence>
                                   <xs:element
name="node21"/>
                                   <xs:element
name="node22"/>
                              </xs:sequence>
                         </xs:complexType>
                    </xs:element>
               </xs:sequence>
               <xs:attribute name="attr1" type="xs:string"
use="optional"/>
          </xs:complexType>
     </xs:element>
</xs:schema>


-----Original Message-----
From: Elena Litani [mailto:elitani@ca.ibm.com]
Sent: Thursday, February 21, 2002 12:50 PM
To: xerces-j-user@xml.apache.org
Subject: Re: XMLSerializer problem


Hi,

I could not reproduce your problem with the newest jars:
http://gump.covalent.net/jars/latest/xml-xerces2/
Can you verify that it is fixed in the new version?

Thank you!
Elena

Cirip Tomas wrote:
>
> Hi,
>
> I am trying to use XMLSerializer to write XML document to a file. In the
> result I get xmlns:xsi attribute twice. I used it before and I think it
was
> working ok before. I downloaded latest xerces jars. Any ideas?
>
> Java code:
>
>       DOMParser parser = new DOMParser();
>       parser.parse("file:///d:\\tc\\xml\\test_schema.xml");
>       Document doc = parser.getDocument();
>
>       OutputFormat outputFormat = new OutputFormat(doc);
>       outputFormat.setIndenting(true);
>
>       XMLSerializer serializer = new XMLSerializer(System.out,
> outputFormat);
>       serializer.serialize(doc);
>
> XML Document:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="D:\tc\xml\test.xsd">
>         <node1 attr1="cvirko">
>                 <node11/>
>                 <node12/>
>         </node1>
>         <node2>
>                 <node21/>
>                 <node22/>
>         </node2>
> </root>
>
> Result after serialization:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="D:\tc\xmlparadise\xml\test.xsd">
>     <node1 attr1="cvirko">
>         <node11/>
>         <node12/>
>     </node1>
>     <node2>
>         <node21/>
>         <node22/>
>     </node2>
> </root>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org

--
Elena Litani / IBM Toronto

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="D:\tc\xmlparadise\xml\test.xsd">
        <node1 attr1="cvirko">
                <node11/>
                <node12/>
        </node1>
        <node2>
                <node21/>
                <node22/>
        </node2>
</root>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org