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/[EMAIL 
> PROTECTED]
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: [EMAIL PROTECTED]
> E-mail: [EMAIL PROTECTED]
> 
> Dick Deneer <[EMAIL PROTECTED]> 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 PROTECTED]
>>     </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 PROTECTED]
>>  </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 PROTECTED]
>>  </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: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to