DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33487>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33487

           Summary: LSSerializer fails when validating external entities
                    with namespaces
           Product: Xerces-J
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: SAX
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


When I try to write a Document with this code:

System.setProperty(DOMImplementationRegistry.PROPERTY,
                        "org.apache.xerces.dom.DOMImplementationSourceImpl");
DOMImplementationRegistry registry =
                                   DOMImplementationRegistry.newInstance();

DOMImplementationLS impl =
                      (DOMImplementationLS)registry.getDOMImplementation("LS");
LSOutput output = impl.createLSOutput();
output.setSystemId(uri);
LSSerializer writer = impl.createLSSerializer();
writer.write(document, output);


I recieve this error:
     [java] java.io.IOException: The replacement text of the entity node
'entity' contains an element node 'example1' with an attribute 'xmlns:exa' an
undeclared prefix 'xmlns'.
     [java]     at 
org.apache.xml.serialize.BaseMarkupSerializer.fatalError(Unknown
Source)
     [java]     at
org.apache.xml.serialize.XMLSerializer.checkUnboundNamespacePrefixedNode(Unknown
Source)
     [java]     at
org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source)
     [java]     at 
org.apache.xml.serialize.XMLSerializer.serializeElement(Unknown
Source)
     [java]     at
org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source)
     [java]     at
org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(Unknown Source)
     [java]     at 
org.apache.xml.serialize.BaseMarkupSerializer.serialize(Unknown
Source)
     [java]     at org.apache.xml.serialize.DOMSerializerImpl.write(Unknown 
Source)

These are the xml files that I am using:
XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE Root PUBLIC "-//Example//DTD Example/EN"
"http://www.example.com/example"; [

<!ENTITY entity SYSTEM 'entity.inc'>
]>

<Root
 name="root"
 xmlns="http://www.example.com/example";     
 xmlns:exa="http://www.example.com/example";>


   &entity;


</Root>

ENTITY:
<?xml version="1.0" encoding="iso-8859-1"?>

<example1 xmlns:exa="http://www.example.com/example";>
   <exa:example2>ss</exa:example2>
</example1>


I have been investigating the source code of Xerces and I think that the error
is in org\apache\xerces\util\NamespaceSupport.java. The method "String
getURI(String prefix)" compare two string but uses "==" instead of "equals". I
have modified this code and previous example does not produce errors.

DIFF between original code and my modified code:

232c232
<             if (fNamespace[i - 2] == prefix) {
---
>             if (fNamespace[i - 2].equals(prefix)) {

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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

Reply via email to