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 Kevin Froese <kf...@opentext.com> on 2007/01/31 20:07:58 UTC
Losing entity references in attributes
Hello.
I'm experiencing some unexpected (at least to me) behavior with entity
references in attributes. After parsing, entity references in attributes
appear to be dropped, leaving only the value of the entity. For example,
starting with the DOM3 class from the samples in the Xerces 2.9.0
distribution, I added the line
config.setParameter("entities", Boolean.TRUE);
just before the call to parseURI(). Then if I run with the modified
personal.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE personnel SYSTEM "personal.dtd" [
<!ENTITY name "Big">
<!ENTITY one "1">
]>
<personnel>
<person id="Big.Boss" salary="&one;">
<name><family>Boss</family> <given>&name;</given></name>
<email>chief@foo.com</email>
</person>
</personnel>
The results I get are:
Parsing data/personal.xml...
Normalizing document...
Serializing document...
<!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
<!ENTITY one '1'>
]>
<personnel>
<person id="Big.Boss" salary="1">
<name><family>Boss</family> <given>&name;</given></name>
<email>chief@foo.com</email>
</person>
</personnel>
While the "name" entity reference remains, the "one" entity reference has
been lost, replaced by the value of the entity. Is this behavior expected?
A bug? Configurable?
Any insight is greatly appreciated.
--
Kevin Froese
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Losing entity references in attributes
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Dick Deneer <di...@donkeydevelopment.com> wrote on 02/18/2007
05:38:47 PM:
> Michael,
> I have a problem with extra lines after the root element (which
> increase by each time I repeat the process from XML to Dom and back
> (using the writeToString method)
> Also the opening of the root is on the same line as the xml
declaration.
>
> Starting with:
> <?xml
version="1.0"?><root><child1>text</child1><child2>text</child2></root>
> Here a print of the output:
> ===================================================
> <?xml version="1.0" ?><root>
> <child1>text</child1>
> <child2>text</child2>
> </root>
> ===================================================
> <?xml version="1.0" ?><root>
>
>
> <child1>text</child1>
> <child2>text</child2>
> </root>
> ===================================================
> <?xml version="1.0" ?><root>
>
>
>
>
> <child1>text</child1>
> <child2>text</child2>
> </root>
> ===================================================
>
> At the moment I can not reproduce it on MacOs, but It happens om
Windows.
That's odd. I don't know the code well enough to say what's going on
there. You might want to ping the xalan list.
> As soon as I change to the Xerces serializer the output is OK.
>
> By the way:
> Can I make a JIRA request regarding to the entity reference issue
> for attributes. Maybe it is worth reconsidering the made design
decision.
> A similar implementation as in elements, with a property setting,
> would solve this problem.
The decision was made before XNI was finalized. I'm not sure how this
could be supported now without breaking XNI or severely hurting
performance but perhaps someone in the future will think of a way. Feel
free to submit a request for enhancement in JIRA.
Thanks.
> Dick Deneer
>
> Op 18-feb-2007, om 0:29 heeft Michael Glavassevich het volgende
geschreven:
>
> Dick Deneer <di...@donkeydevelopment.com> wrote on 02/17/2007
> 06:16:34 PM:
>
> Michael,
>
> Thanks for your analysis.
> It looks like going to the DOM and storing the original entity
> references will not be the problem, but the way back is not possible.
> By the way: I am still using the deprecated Xerces serializer because
> of a problem with pretty-print in the Xalan one.
>
> Out of curiosity, what problem is that?
>
> I will think again what to do.
>
> Thanks
> Dick Deneer
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Losing entity references in attributes
Posted by Dick Deneer <di...@donkeydevelopment.com>.
Michael,
I have a problem with extra lines after the root element (which
increase by each time I repeat the process from XML to Dom and back
(using the writeToString method)
Also the opening of the root is on the same line as the xml declaration.
Starting with:
<?xml version="1.0"?><root><child1>text</child1><child2>text</
child2></root>
Here a print of the output:
===================================================
<?xml version="1.0" ?><root>
<child1>text</child1>
<child2>text</child2>
</root>
===================================================
<?xml version="1.0" ?><root>
<child1>text</child1>
<child2>text</child2>
</root>
===================================================
<?xml version="1.0" ?><root>
<child1>text</child1>
<child2>text</child2>
</root>
===================================================
At the moment I can not reproduce it on MacOs, but It happens om
Windows.
As soon as I change to the Xerces serializer the output is OK.
By the way:
Can I make a JIRA request regarding to the entity reference issue for
attributes. Maybe it is worth reconsidering the made design decision.
A similar implementation as in elements, with a property setting,
would solve this problem.
Dick Deneer
Op 18-feb-2007, om 0:29 heeft Michael Glavassevich het volgende
geschreven:
> Dick Deneer <di...@donkeydevelopment.com> wrote on 02/17/2007
> 06:16:34 PM:
>
>> Michael,
>>
>> Thanks for your analysis.
>> It looks like going to the DOM and storing the original entity
>> references will not be the problem, but the way back is not possible.
>> By the way: I am still using the deprecated Xerces serializer because
>> of a problem with pretty-print in the Xalan one.
>
> Out of curiosity, what problem is that?
>
>> I will think again what to do.
>>
>> Thanks
>> Dick Deneer
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>
Re: Losing entity references in attributes
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Dick Deneer <di...@donkeydevelopment.com> wrote on 02/17/2007
06:16:34 PM:
> Michael,
>
> Thanks for your analysis.
> It looks like going to the DOM and storing the original entity
> references will not be the problem, but the way back is not possible.
> By the way: I am still using the deprecated Xerces serializer because
> of a problem with pretty-print in the Xalan one.
Out of curiosity, what problem is that?
> I will think again what to do.
>
> Thanks
> Dick Deneer
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Losing entity references in attributes
Posted by Dick Deneer <di...@donkeydevelopment.com>.
Michael,
Thanks for your analysis.
It looks like going to the DOM and storing the original entity
references will not be the problem, but the way back is not possible.
By the way: I am still using the deprecated Xerces serializer because
of a problem with pretty-print in the Xalan one.
I will think again what to do.
Thanks
Dick Deneer
Op 17-feb-2007, om 16:18 heeft Michael Glavassevich het volgende
geschreven:
> Dick Deneer <di...@donkeydevelopment.com> wrote on 02/16/2007
> 03:25:18 PM:
>
>> I would like to build a workaround for this issue for my xml editor
> tool. I
>> am thinking of the following solution. When I parse the xml to a
>> DOM, I
> want
>> to store the entity as userdata in the attribute node and restrict
>> the
> user
>> from editing the attribute value while working in the DOM tree view.
> When
>> serializing the tree back to a xml source I want to put the orignal
> entity
>> value back in the xml string. I have the following questions about
>> implementing this.
>>
>> Parsing to the DOM.
>> At this moment I am using:
>>
>> DOMImplementationRegistry registry =
>> DOMImplementationRegistry.newInstance();
>> impl = (DOMImplementationLS) registry.getDOMImplementation("psvi");
>> parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,
> null);
>>
>> Fo my solution I have to do something like in the DOMAddLines.java
> example.
>> I have to extend the DOMParser to get access to the DocumentHandler.
>> I want to extend DOMParserImpl and then in the constructor call
>> super
>> ("org.apache.xerces.parsers.XIncludeAwareParserConfiguration",null)
>> Is this the best way, because I see the DOMAddlines.java example
>> extends
>> DOMParser.
>
> The unprocessed text (including the entity references) of each
> attribute
> value is available from
> org.apache.xerces.xni.XMLAttributes.getNonNormalizedValue(). I assume
> that's what you'd want to store as user data. The only way you can
> get to
> this information is by extending the DOMParser.
>
>> Serializing the DOM.
>> My second questions is th serialize step. I am wondering where I can
>> interfere in the serializer to get the userdate of the attributes and
> put
>> back the original (entity-) value.
>
> I just glanced at both the Xerces and Xalan serializers and I don't
> think
> it's possible for you to do that. Even if you wrote a microparser for
> attribute values and replaced the children of each attribute with
> text and
> entity reference nodes, both serializers just call Node.getNodeValue
> () or
> Attr.getValue() [1] to get the value as a string so would never
> look at
> the entity references.
>
>> Suggestion are very welcome
>> Dick Deneer
>>
>> --
>> View this message in context: http://www.nabble.com/Losing-entity-
>> references-in-attributes-tf3150674.html#a9011759
>> Sent from the Xerces - J - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-users-help@xerces.apache.org
>
> [1]
> http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/
> core.html#ID-221662474
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Losing entity references in attributes
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Dick Deneer <di...@donkeydevelopment.com> wrote on 02/16/2007
03:25:18 PM:
> I would like to build a workaround for this issue for my xml editor
tool. I
> am thinking of the following solution. When I parse the xml to a DOM, I
want
> to store the entity as userdata in the attribute node and restrict the
user
> from editing the attribute value while working in the DOM tree view.
When
> serializing the tree back to a xml source I want to put the orignal
entity
> value back in the xml string. I have the following questions about
> implementing this.
>
> Parsing to the DOM.
> At this moment I am using:
>
> DOMImplementationRegistry registry =
> DOMImplementationRegistry.newInstance();
> impl = (DOMImplementationLS) registry.getDOMImplementation("psvi");
> parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,
null);
>
> Fo my solution I have to do something like in the DOMAddLines.java
example.
> I have to extend the DOMParser to get access to the DocumentHandler.
> I want to extend DOMParserImpl and then in the constructor call
> super("org.apache.xerces.parsers.XIncludeAwareParserConfiguration",null)
> Is this the best way, because I see the DOMAddlines.java example extends
> DOMParser.
The unprocessed text (including the entity references) of each attribute
value is available from
org.apache.xerces.xni.XMLAttributes.getNonNormalizedValue(). I assume
that's what you'd want to store as user data. The only way you can get to
this information is by extending the DOMParser.
> Serializing the DOM.
> My second questions is th serialize step. I am wondering where I can
> interfere in the serializer to get the userdate of the attributes and
put
> back the original (entity-) value.
I just glanced at both the Xerces and Xalan serializers and I don't think
it's possible for you to do that. Even if you wrote a microparser for
attribute values and replaced the children of each attribute with text and
entity reference nodes, both serializers just call Node.getNodeValue() or
Attr.getValue() [1] to get the value as a string so would never look at
the entity references.
> Suggestion are very welcome
> Dick Deneer
>
> --
> View this message in context: http://www.nabble.com/Losing-entity-
> references-in-attributes-tf3150674.html#a9011759
> Sent from the Xerces - J - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
[1]
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-221662474
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Losing entity references in attributes
Posted by Dick Deneer <di...@donkeydevelopment.com>.
I would like to build a workaround for this issue for my xml editor tool. I
am thinking of the following solution. When I parse the xml to a DOM, I want
to store the entity as userdata in the attribute node and restrict the user
from editing the attribute value while working in the DOM tree view. When
serializing the tree back to a xml source I want to put the orignal entity
value back in the xml string. I have the following questions about
implementing this.
Parsing to the DOM.
At this moment I am using:
DOMImplementationRegistry registry =
DOMImplementationRegistry.newInstance();
impl = (DOMImplementationLS) registry.getDOMImplementation("psvi");
parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
Fo my solution I have to do something like in the DOMAddLines.java example.
I have to extend the DOMParser to get access to the DocumentHandler.
I want to extend DOMParserImpl and then in the constructor call
super("org.apache.xerces.parsers.XIncludeAwareParserConfiguration",null)
Is this the best way, because I see the DOMAddlines.java example extends
DOMParser.
Serializing the DOM.
My second questions is th serialize step. I am wondering where I can
interfere in the serializer to get the userdate of the attributes and put
back the original (entity-) value.
Suggestion are very welcome
Dick Deneer
Michael Glavassevich wrote:
>
> XNI doesn't report entity boundaries in attribute values. This was a
> design decision made long before I arrived on the scene. See the rationale
> here [1].
>
> [1]
> http://mail-archives.apache.org/mod_mbox/xerces-j-dev/200109.mbox/%3c3B9C5915.E05D28AC@apache.org%3e
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Dick Deneer <di...@donkeydevelopment.com> wrote on 01/31/2007
> 02:59:06 PM:
>
>> Kevin,
>>
>> Sorry, I did not look well to your result.
>> It is exactly the same as mine.
>> So I guess I have the same issue.
>>
>> Dick Deneer
>> Op 31-jan-2007, om 20:45 heeft Dick Deneer het volgende geschreven:
>>
>> Hi Keven,
>>
>> I tried your xml in my tool which also used DOM3
>> I parse, normalize and serialize and guess what I get? :))
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
>> <!ENTITY one '1'>
>> ]>
>> <personnel>
>> <person id="Big.Boss" salary="1">
>> <name>
>> <family>Boss</family>
>> <given>&name;</given>
>> </name>
>> chief@foo.com
>> </person>
>> </personnel>
>>
>> I am using config.setParameter(
>> "http://apache.org/xml/features/dom/create-entity-ref-nodes",
>> Boolean.TRUE);
>> to retain the entitynodes in the DOM.
>>
>> So maybe the combination gives the goor result?
>>
>> Regards
>> Dick
>>
>> Op 31-jan-2007, om 20:07 heeft Kevin Froese het volgende geschreven:
>>
>> Hello.
>>
>> I'm experiencing some unexpected (at least to me) behavior with entity
>> references in attributes. After parsing, entity references in attributes
>> appear to be dropped, leaving only the value of the entity. For example,
>> starting with the DOM3 class from the samples in the Xerces 2.9.0
>> distribution, I added the line
>>
>> config.setParameter("entities", Boolean.TRUE);
>>
>> just before the call to parseURI(). Then if I run with the modified
>> personal.xml file:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE personnel SYSTEM "personal.dtd" [
>> <!ENTITY name "Big">
>> <!ENTITY one "1">
>> ]>
>>
>> <personnel>
>>
>> <person id="Big.Boss" salary="&one;">
>> <name><family>Boss</family> <given>&name;</given></name>
>> chief@foo.com
>> </person>
>> </personnel>
>>
>> The results I get are:
>>
>> Parsing data/personal.xml...
>> Normalizing document...
>> Serializing document...
>> <!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
>> <!ENTITY one '1'>
>> ]>
>> <personnel>
>>
>> <person id="Big.Boss" salary="1">
>> <name><family>Boss</family> <given>&name;</given></name>
>> chief@foo.com
>> </person>
>>
>> </personnel>
>>
>> While the "name" entity reference remains, the "one" entity reference
> has
>> been lost, replaced by the value of the entity. Is this behavior
> expected?
>> A bug? Configurable?
>>
>> Any insight is greatly appreciated.
>>
>> --
>> Kevin Froese
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-users-help@xerces.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Losing-entity-references-in-attributes-tf3150674.html#a9011759
Sent from the Xerces - J - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Losing entity references in attributes
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
XNI doesn't report entity boundaries in attribute values. This was a
design decision made long before I arrived on the scene. See the rationale
here [1].
[1]
http://mail-archives.apache.org/mod_mbox/xerces-j-dev/200109.mbox/%3c3B9C5915.E05D28AC@apache.org%3e
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Dick Deneer <di...@donkeydevelopment.com> wrote on 01/31/2007
02:59:06 PM:
> Kevin,
>
> Sorry, I did not look well to your result.
> It is exactly the same as mine.
> So I guess I have the same issue.
>
> Dick Deneer
> Op 31-jan-2007, om 20:45 heeft Dick Deneer het volgende geschreven:
>
> Hi Keven,
>
> I tried your xml in my tool which also used DOM3
> I parse, normalize and serialize and guess what I get? :))
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
> <!ENTITY one '1'>
> ]>
> <personnel>
> <person id="Big.Boss" salary="1">
> <name>
> <family>Boss</family>
> <given>&name;</given>
> </name>
> <email>chief@foo.com</email>
> </person>
> </personnel>
>
> I am using config.setParameter(
> "http://apache.org/xml/features/dom/create-entity-ref-nodes",
> Boolean.TRUE);
> to retain the entitynodes in the DOM.
>
> So maybe the combination gives the goor result?
>
> Regards
> Dick
>
> Op 31-jan-2007, om 20:07 heeft Kevin Froese het volgende geschreven:
>
> Hello.
>
> I'm experiencing some unexpected (at least to me) behavior with entity
> references in attributes. After parsing, entity references in attributes
> appear to be dropped, leaving only the value of the entity. For example,
> starting with the DOM3 class from the samples in the Xerces 2.9.0
> distribution, I added the line
>
> config.setParameter("entities", Boolean.TRUE);
>
> just before the call to parseURI(). Then if I run with the modified
> personal.xml file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE personnel SYSTEM "personal.dtd" [
> <!ENTITY name "Big">
> <!ENTITY one "1">
> ]>
>
> <personnel>
>
> <person id="Big.Boss" salary="&one;">
> <name><family>Boss</family> <given>&name;</given></name>
> <email>chief@foo.com</email>
> </person>
> </personnel>
>
> The results I get are:
>
> Parsing data/personal.xml...
> Normalizing document...
> Serializing document...
> <!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
> <!ENTITY one '1'>
> ]>
> <personnel>
>
> <person id="Big.Boss" salary="1">
> <name><family>Boss</family> <given>&name;</given></name>
> <email>chief@foo.com</email>
> </person>
>
> </personnel>
>
> While the "name" entity reference remains, the "one" entity reference
has
> been lost, replaced by the value of the entity. Is this behavior
expected?
> A bug? Configurable?
>
> Any insight is greatly appreciated.
>
> --
> Kevin Froese
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Losing entity references in attributes
Posted by Dick Deneer <di...@donkeydevelopment.com>.
Kevin,
Sorry, I did not look well to your result.
It is exactly the same as mine.
So I guess I have the same issue.
Dick Deneer
Op 31-jan-2007, om 20:45 heeft Dick Deneer het volgende geschreven:
> Hi Keven,
>
> I tried your xml in my tool which also used DOM3
> I parse, normalize and serialize and guess what I get? :))
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
> <!ENTITY one '1'>
> ]>
> <personnel>
> <person id="Big.Boss" salary="1">
> <name>
> <family>Boss</family>
> <given>&name;</given>
> </name>
> <email>chief@foo.com</email>
> </person>
> </personnel>
>
>
> I am using config.setParameter(
> "http://apache.org/xml/features/dom/create-entity-ref-nodes",
> Boolean.TRUE);
> to retain the entitynodes in the DOM.
>
> So maybe the combination gives the goor result?
>
> Regards
> Dick
>
> Op 31-jan-2007, om 20:07 heeft Kevin Froese het volgende geschreven:
>
>> Hello.
>>
>> I'm experiencing some unexpected (at least to me) behavior with
>> entity
>> references in attributes. After parsing, entity references in
>> attributes
>> appear to be dropped, leaving only the value of the entity. For
>> example,
>> starting with the DOM3 class from the samples in the Xerces 2.9.0
>> distribution, I added the line
>>
>> config.setParameter("entities", Boolean.TRUE);
>>
>> just before the call to parseURI(). Then if I run with the modified
>> personal.xml file:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE personnel SYSTEM "personal.dtd" [
>> <!ENTITY name "Big">
>> <!ENTITY one "1">
>> ]>
>>
>> <personnel>
>>
>> <person id="Big.Boss" salary="&one;">
>> <name><family>Boss</family> <given>&name;</given></name>
>> <email>chief@foo.com</email>
>> </person>
>> </personnel>
>>
>> The results I get are:
>>
>> Parsing data/personal.xml...
>> Normalizing document...
>> Serializing document...
>> <!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
>> <!ENTITY one '1'>
>> ]>
>> <personnel>
>>
>> <person id="Big.Boss" salary="1">
>> <name><family>Boss</family> <given>&name;</given></name>
>> <email>chief@foo.com</email>
>> </person>
>>
>> </personnel>
>>
>> While the "name" entity reference remains, the "one" entity
>> reference has
>> been lost, replaced by the value of the entity. Is this behavior
>> expected?
>> A bug? Configurable?
>>
>> Any insight is greatly appreciated.
>>
>>
>> --
>> Kevin Froese
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
>> For additional commands, e-mail: j-users-help@xerces.apache.org
>>
>>
>>
>
Re: Losing entity references in attributes
Posted by Dick Deneer <di...@donkeydevelopment.com>.
Hi Keven,
I tried your xml in my tool which also used DOM3
I parse, normalize and serialize and guess what I get? :))
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
<!ENTITY one '1'>
]>
<personnel>
<person id="Big.Boss" salary="1">
<name>
<family>Boss</family>
<given>&name;</given>
</name>
<email>chief@foo.com</email>
</person>
</personnel>
I am using config.setParameter(
"http://apache.org/xml/features/dom/create-entity-ref-nodes",
Boolean.TRUE);
to retain the entitynodes in the DOM.
So maybe the combination gives the goor result?
Regards
Dick
Op 31-jan-2007, om 20:07 heeft Kevin Froese het volgende geschreven:
> Hello.
>
> I'm experiencing some unexpected (at least to me) behavior with entity
> references in attributes. After parsing, entity references in
> attributes
> appear to be dropped, leaving only the value of the entity. For
> example,
> starting with the DOM3 class from the samples in the Xerces 2.9.0
> distribution, I added the line
>
> config.setParameter("entities", Boolean.TRUE);
>
> just before the call to parseURI(). Then if I run with the modified
> personal.xml file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE personnel SYSTEM "personal.dtd" [
> <!ENTITY name "Big">
> <!ENTITY one "1">
> ]>
>
> <personnel>
>
> <person id="Big.Boss" salary="&one;">
> <name><family>Boss</family> <given>&name;</given></name>
> <email>chief@foo.com</email>
> </person>
> </personnel>
>
> The results I get are:
>
> Parsing data/personal.xml...
> Normalizing document...
> Serializing document...
> <!DOCTYPE personnel SYSTEM "personal.dtd" [<!ENTITY name 'Big'>
> <!ENTITY one '1'>
> ]>
> <personnel>
>
> <person id="Big.Boss" salary="1">
> <name><family>Boss</family> <given>&name;</given></name>
> <email>chief@foo.com</email>
> </person>
>
> </personnel>
>
> While the "name" entity reference remains, the "one" entity
> reference has
> been lost, replaced by the value of the entity. Is this behavior
> expected?
> A bug? Configurable?
>
> Any insight is greatly appreciated.
>
>
> --
> Kevin Froese
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>
>