Subject: [xsl] Request for Help From: "B. Tommie Usdin" <btusdin@xxxxxxxxxxxxxxxx> Date: Mon, 29 Jan 2001 11:17:32 -0500 |
From: fernando@xxxxxxxxx Received: (cpmta 9211 invoked from network); 29 Jan 2001 07:35:29 -0800 Date: 29 Jan 2001 07:35:29 -0800 Message-ID: <20010129153529.9210.cpmta@xxxxxxxxxxxxxxx> X-Sent: 29 Jan 2001 15:35:29 GMT Received: from [62.175.116.126] by mail.lopez.org with HTTP; 29 Jan 2001 07:35:29 PST Content-Type: text/plain Content-Disposition: inline Mime-Version: 1.0 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx X-Mailer: Web Mail 3.7.1.7 Subject: Help, Please
Hi,
I am newbie in xsl. I hava a problem I really need your help. I use this XSL style sheet to transform one XML file as follows:
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version = "1.0">
<xsl:output method="xml" encoding="ISO-8859-1" indent="yes" omit-xml-declaration="no"/>
<xsl:template match="*"> <xsl:copy> <xsl:copy-of select = "@*"/> <xsl:attribute name="id"><xsl:call-template name="object.id"/></xsl:attribute> <xsl:choose> <xsl:when test="child::*"> <xsl:apply-templates/> </xsl:when> <xsl:otherwise> <xsl:value-of select="." disable-output-escaping="yes"/> </xsl:otherwise> </xsl:choose> </xsl:copy> </xsl:template>
<!-- ====================================================================== -->
<xsl:template name="object.id">
<xsl:param name="object" select="."/>
<xsl:choose>
<xsl:when test="$object/@id">
<xsl:value-of select="$object/@id" disable-output-escaping="yes"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="ancestor-or-self::*">
<xsl:value-of select="concat(generate-id(.),'Ps',position())" disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
It works ok for me except that I need to keep all the data unchanged, for example:
<?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE root [ <!ENTITY amp "&#38;"> <!-- AMPERSAND --> ]> <root> <data>Hello world</data> </root>
generate:
<?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE root > <root id="1"> <data id="2">Hello world</data> </root>
But:
<?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE root [ <!ENTITY amp "&#38;"> <!-- AMPERSAND --> ]> <root> <data>Stand & Hardy</data> </root>
generate:
<?xml version='1.0' encoding='ISO-8859-1'?> <!DOCTYPE root > <root id="1"> <data id="2">Stand & Hardy</data> </root>
This cause that the next transformation based on this XML results fails. Because the ampersand entity has been translated.
Thanks in advance, Fernando LÛpez Carballeda
PS.- Do not hesitate to correct me.
-- ====================================================================== B. Tommie Usdin mailto:btusdin@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Phone: 301/315-9631 Suite 207 Direct Line: 301/315-9634 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Document Function, Ankur N | Thread | RE: [xsl] Request for Help, Michael Kay |
[xsl] Document Function, Ankur N | Date | [xsl] Complex HTML Table, B. Tommie Usdin |
Month |