Bug 33487 - LSSerializer fails when validating external entities with namespaces
Summary: LSSerializer fails when validating external entities with namespaces
Status: NEW
Alias: None
Product: Xerces-J
Classification: Unclassified
Component: SAX (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Xerces-J Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-10 11:33 UTC by ijorge
Modified: 2005-02-10 05:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ijorge 2005-02-10 11:33:58 UTC
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)) {
Comment 1 Michael Glavassevich 2005-02-10 14:06:22 UTC
New bugs, or modifications to existing bugs should be made using JIRA. Some 
time ago tracking of bugs and issues in Xerces moved from Bugzilla to JIRA at: 
http://nagoya.apache.org/jira. Please open this bug report there.

The URL for Xerces in JIRA is: http://issues.apache.org/jira/browse/XERCESJ. In 
order to create a new bug or issue in JIRA, you will need to create a JIRA 
account (assuming you don't already have one).