This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
=?UTF-8?B?UkU6IFt4c2xdIFhTTCB0cmFuc2Zvcm1hdGlvbiBwcm9ibGVtIChY?==?UTF-8?B?U0wgLT4gWE1MKSAuLi4=?=
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] =?UTF-8?B?UkU6IFt4c2xdIFhTTCB0cmFuc2Zvcm1hdGlvbiBwcm9ibGVtIChY?==?UTF-8?B?U0wgLT4gWE1MKSAuLi4=?=
- From: bryan dot s dot schnabel at exgate dot tek dot com
- Date: Mon, 12 Mar 2001 12:57:59 -0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
One way to achieve this would be to include this template:
<xsl:template match="xsl:for-each">
</xsl:template>
Bryan
-----Original Message-----
From: Ough, Cameron [mailto:cameron.ough@intel.com]
Sent: Monday, March 12, 2001 11:59 AM
To: 'XSL-List@lists.mulberrytech.com'
Subject: [xsl] XSL transformation problem (XSL -> XML) ...
The problem is that I am trying to extract content from an XSL doc using
XSLT to transform into XML (see the example below). Problem is that I am
getting the text from the previous sections of the XSL, which is unwanted
(notice the "This is the chapter:" text in the output). Can someone provide
some direction on this?
Original XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:foo="http://someplace.com/foo"
extension-element-prefixes="foo">
<xsl:template match="/"> <!--root rule-->
<html>
<head><title></title></head>
<body>
<h1><xsl:value-of select="doc/title"/></h1>
<hr/>
<xsl:for-each select="doc/chapter">
This is the chapter:<br/>
<h2><xsl:value-of select="title"/></h2>
<xsl:apply-templates />
</xsl:for-each>
</body>
</html>
</xsl:template>
<foo:months locale="en-us">
<month>January</month>
<month>February</month>
<month>March</month>
</foo:months>
</xsl:stylesheet>
Applied transformation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:foo="http://someplace.com/foo"
exclude-result-prefixes="xsl">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="foo:months[@locale='en-us']">
<xsl:element name="locale">
<xsl:attribute name="id"><xsl:value-of
select="@locale"/></xsl:attribute>
<xsl:apply-templates select="month"/>
</xsl:element>
</xsl:template>
<xsl:template match="month">
<xsl:if test="parent::*[@locale='en-us']">
<xsl:element name="month">
<xsl:value-of select="."/>
</xsl:element>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Output XML:
<?xml version="1.0" encoding="utf-8"?>
This is the chapter:<locale id="en-us">
<month>January</month>
<month>February</month>
<month>March</month>
</locale>
Thanks,
Cameron
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list