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

Re: Elements with Mixed contents

Subject: Re: Elements with Mixed contents
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 14 Feb 2002 14:06:28 +0000
xslt mixed element
Hi Sandeep,

> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">

You're not using XSLT, but rather a dialect developed by Microsoft
based on one of the very early working drafts for XSLT, which they
call "XSL". I suggest that you upgrade to XSLT before you go any
further. See the MSXML FAQ at
http://www.netcrucible.com/xslt/msxml-faq.htm for more details.

> <xsl:template match="directory">
>  <br/><xsl:value-of select="text()"/><br/>
> <xsl:apply-templates select="subdirectory"/>
>  <br/><xsl:value-of select="text()[1]"/><br/>
> </xsl:template>

I can't say how "XSL" would interpret this, but in XSLT the positions
of nodes are counted from 1. The above will give you the value of the
first text node twice - once from the <xsl:value-of select="text()" />
and once from the <xsl:value-of select="text()[1]" />.

But I think that you're going about the problem in the wrong way. It
seems that what you want is, for every text node in your document, a
br element followed by the value of the text node, followed by a br
element. You should make a template that expresses that rule, as

<xsl:template match="text()">
  <br /><xsl:value-of select="." /><br />

Then, the templates for directory and subdirectory elements can simply
apply templates to all their children, without having to test to see
what they are, as follows:

<xsl:template match="directory">
  <xsl:apply-templates />

<xsl:template match="subdirectory">
  <font color="red">
    <xsl:apply-templates />

<xsl:template match="file">
  <font color="blue">
    <br/><xsl:value-of select="."/>

I hope that helps,


Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.