Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[higgins-dev] Re: [dom4j-user] Adding entity references to an attribute value

Yes, generating entity references is certainly something I'd prefer to do.  It'll save a LOT of size on my document not to mention readability.  References to other definitions and types is a part of pretty much every RDF\OWL definition, usually several times per definition.

Anyway, thank you very much Edwin for the suggestion.  I tried it and it works as you expected.  I went ahead and left the escapeText property at it's default since any time I set text, I would want the escapement to occur.

Regards,
Tom Doman
Novell Inc.

>>> "Edwin Dankert" <edankert@xxxxxxxxx> 9/29/2006 3:00 AM >>>
The philosophy behind this is that entities are used to substitute text
inside a document, mainly to support human entry of the text, however
when generating the document programmatically, the developer can
use the programming language to facilitate him in creating the document
so there should not be a need for these entities and therefor dom4j's
entity support for serialization is not very good.

So, my recommendation would be not to try to generate Entities using
dom4j, however if you really need to ...

For elements you can set the 'escapeText' property as a work-around,
this property however does not seem to work for attributes.

So instead, you will have to override the escapeAttributeEntities method.

I haven't tested the following but it should work:

public class EscapedXMLWriter extends XMLWriter {
  protected String escapeAttributeEntities(String text) {
    return text;
  }
}

Regards,
Edwin
-- 
http://www.edankert.com/


Back to the top