[
Lists Home |
Date Index |
Thread Index
]
Simpler, what about something around those lines:
Entity declaration:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0"?>
<e:entities xmlns:e="http://dyomedea.com/ns/entities"
xmlns="http://www.w3.org/1999/xhtml">
<e:element name="nbsp"
ns="http://www.w3.org/1999/xhtml"> </e:element>
<e:element name="signature" ns="http://www.w3.org/1999/xhtml">
<p>Eric van der Vlist</p>
</e:element>
</e:entities>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Document:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0"?>
<html e:use="entities.xml" xmlns:e="http://dyomedea.com/ns/entities"
xmlns="http://www.w3.org/1999/xhtml" >
<body>
<div>
<p>This is a non breaking space: "<nbsp/>"</p>
<signature/>
</div>
</body>
</html>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Processed through something such as:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:e="http://dyomedea.com/ns/entities"
>
<xsl:param name="entities" select="/*/@e:use"/>
<xsl:key name="elements" match="e:element" use="concat(@ns, ' ',
@name)"/>
<xsl:template match="@e:use"/>
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
<xsl:template match="*">
<xsl:variable name="node" select="."/>
<xsl:variable name="expanded-name" select="concat(namespace-uri(), '
', local-name())"/>
<xsl:for-each select="document($entities)">
<xsl:choose>
<xsl:when test="key('elements', $expanded-name)">
<xsl:apply-templates select="key('elements',
$expanded-name)/node()"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$node">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:transform>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
That gives:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0"?>
<html xmlns:e="http://dyomedea.com/ns/entities"
xmlns="http://www.w3.org/1999/xhtml">
<body>
<div>
<p>This is a non breaking space: " "</p>
<p foo="bar">Eric van der Vlist</p>
</div>
</body>
</html>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This could be seen as a generic way to formalise using empty elements as
references to "entities".
My (other) 0.02 Euros.
Eric
--
Read me on XMLhack.
http://xmlhack.com/author.php?id=8
Upcoming schema tutorial:
- Philadelphia (7/12/2003) http://makeashorterlink.com/?V28612FC5
Tutoriel XSLT:
- Paris (25/11/2003) http://makeashorterlink.com/?L2C623FC5
------------------------------------------------------------------------
Eric van der Vlist http://xmlfr.org http://dyomedea.com
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------
|