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

XSL transformation problem (XSL -> XML) ...

Subject: XSL transformation problem (XSL -> XML) ...
From: "Ough, Cameron" <cameron.ough@xxxxxxxxx>
Date: Mon, 12 Mar 2001 11:59:23 -0800
xsl locale month
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

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
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.