This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Request for Help
- To: xsl-list <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Request for Help
- From: "B. Tommie Usdin" <btusdin at mulberrytech dot com>
- Date: Mon, 29 Jan 2001 11:17:32 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
>From: fernando@lopez.org
>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@c000.snv.cp.net>
>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@lists.mulberrytech.com
>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@mulberrytech.com
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
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list