Jump to content
Sign in to follow this  
Guest asmodex

Dtd Entities As Macros

Recommended Posts

Guest asmodex

Hi!Sorry if I posted this in the wrong forum, but after several hours in W3C Schools and google this is my last hope.I have a large XML that is full of repeating nodes:

<parent id="1" value="Tom" option="x">	<child id="a" value="first" />	<child id="b" value="second" /></parent><parent id="2" value="######" option="x">	<child id="a" value="first" />	<child id="b" value="second" /></parent>

It would be nice if I could put the child nodes in an entity so that the result would be:

<parent id="1" value="Tom" option="x">&macro;</parent><parent id="2" value="######" option="x">&macro;</parent>

, or even part of the parent node as well:

<parent id="1" value="Tom" &macro;</parent><parent id="2" value="######" &macro;

I've seen examples for this inside DTD, but I need it inside an XML file. If I'm not mistaken parsed parameter entities sound like the right tool:

<!ENTITY macro "<child id="a" value="first" /><child id="b" value="second" />">

I hope that this is possible, and that I'm just too dumb to see how.

Share this post


Link to post
Share on other sites

Entities are only allowed within text nodes. I think they may contain raw XML contents (i.e. elements with attributes and everything), but this means only your first example may work.Entities are defined with DTD, and used in XML, so it's impossible not to use DTD. You can however embed DTD within an XML document. For example:

<?xml version="1.0"?><!DOCTYPE root [<!ENTITY macro "<child id="a" value="first" /><child id="b" value="second" />">]><root><parent id="1" value="Tom" option="x">&macro;</parent><parent id="2" value="######" option="x">&macro;</parent></root>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...