Subject: [xsl] XSL transformation problem (XSL -> XML) ... From: "Ough, Cameron" <cameron.ough@xxxxxxxxx> Date: Mon, 12 Mar 2001 11:59:23 -0800 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] javax.xml.transform.Transform, Satish Patil | Thread | [xsl] namespace values, Kevin_Gutch |
RE: [xsl] mismatched tags with xsl:, Michael Kay | Date | [xsl] namespace values, Kevin_Gutch |
Month |