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

[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: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

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

Reply via email to