Hi all,

I am trying to use DOM4j to create OWL ontology documents.  It's working just 
how I want with one exception.  My attempt to add entity references yields 
encoded ampersand characters.  I need to add entity references in attribute 
values for my OWL definitions.  For example, I need:

<rdfs:label rdf:datatype="&xsd;string">myCoolThing</rdfs:label>

but I get:

<rdfs:label rdf:datatype="&amp;xsd;string">myCoolThing</rdfs:label>

The OWL editors I used so far (Protege and SemanticWorks) don't like what, in 
essence, ends up being nested entity references.

I realize that, with the following code, the encoding of the ampersand is the 
right thing for DOM4j to do when I call asXML() on my document ...

        childElem = (DOMElement)itemElem.addElement("rdfs:label");
        childElem.addAttribute("rdf:datatype", "&xsd;string");
        childElem.addText(itemName);

but I'd like to know how to correctly add the entity reference in the attribute 
value using DOM4j.  I looked for examples of how to use the EntityReference API 
but couldn't find any nor do I know if this is the API that I'd need to use to 
achieve the desired result.  Perhaps there's a way to temporarily disable the 
encoding while I add the attribute value?

Can anyone here enlighten me?

BTW, FWIW, I was able to figure out how to get DOM4j to produce the internal 
entity declarations I need and that works just fine ... though that doesn't 
really have anything to do with getting my entity references to come out right, 
it does mean I'll be good to go if I can.

Thanks,
Tom Doman
Novell Inc.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to