[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Yet Alternative "character entity" proposal


alternative to nbsp
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">&#160;</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: "&#xA0;"</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
------------------------------------------------------------------------


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.