Hi,

I had this problem few days ago. I simply wrote my own tiny DTD with entities and structure declaration.

You can use internal DTD subset, like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE xmlroot [
<!ENTITY myent "expand my entity to something more useful" >
<!ENTITY another "another entity ..." >
]>

<document>
your normal xml document, with &myent; and yet &another; entity...
</document>

-Peter Stibrany

Paul Dlug wrote:

On Jan 29, 2005, at 12:55 PM, Edwin Dankert wrote:

I'm not sure if I understand fully what you're trying to do?
Could you give an example of an input and output document
and maybe some code?


Sure, example document:

<document>
  <title>This is my test document</title>
  <content>This is some content with an entity here: &myent;</content>
</document>

Then substitute the entities by looking up their replacements and running it through XSLT to get:

<html>
  <head><title>This is my test document</title></head>
  <body>
    This is some content with an entity here: myent
  <body>
</html>

In this instance &myent; is replaced with the closest plain text match so the web browser will display it properly. This is done according to a Map:

myentities.add("&myent;", "myent");
myentities.add("&pi;", "PI");

Right now I have a class implementing the Visitor pattern:
public void visit(Entity entity) {
System.out.println("Entity: " + myentities.get(entity.getName()));
}


The problem is that I have no where to put the entity once I lookup it's substitution, the only thing I could do would be to create a new Node with the the Visitor, add the substituted entities in as text nodes, pass the other nodes straight through. Then I would run this through XSLT, which seems expensive since it's traversing the Node twice, once to substitute, then again to do the transformation (plus keeping a duplicate Node with the substituted entities in it).


Thanks, Paul



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to