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

Re: text() and not()

Subject: Re: text() and not()
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Tue, 8 Jan 2002 16:28:37 -0500
Re:  text() and not()
I'm not sure if this answers your question because I can't tell if all the
elements you want to treat like this have the same construction, and I'm not
sure if you literally want "xref" in the output, but here is a simple set of
templates that uses recursion to output what you say you want.

============ Stylesheet ============
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<result>
 <xsl:apply-templates select='title'/>
</result>
</xsl:template>

<xsl:template match='title'>
<xsl:call-template name='matchtext'/>
</xsl:template>

<xsl:template name='matchtext'>
<xsl:copy-of select='text()'/>
<xsl:for-each select='*'>
 <xsl:if test='name()="xref"'>xref</xsl:if>
 <xsl:call-template name='matchtext'/>
</xsl:for-each>
</xsl:template>

<xsl:template match='*'/>
</xsl:stylesheet>

============= Result ==============
<result>
  Renew LP Piston Seal (Fig 5.5.1

 xref
    )
  </result>

(I wrapped the output in a <result> element - of course, it could be
anything.  You can get rid of the extra whitespace by using
normalize-space(text()) if you care about that).

If you want to output something else instead of "xref" it should be clear
where to make corresponding changes.

Cheers,

Tom P

[Andrew Welch]>
> I have a problem with the default template, text() and an element within
> another element.
>
> <title>
>   Renew LP Piston Seal (Fig 5.5.1
>   <xref xrefid="F5.5.1" xidtype="FIGURE">
>     )
>   </xref>
> </title>
>
> I want this to output as:
>
> Renew LP Piston Seal (Fig 5.5.1 xref )
>
> where 'xref' will be replaced by a graphic.
>
> I am overriding the default template using
>
> <xsl:template match=text()/>
>
> because there are several hundred elements that arent for display.
However,
> matching <xref> with a separate template and overriding the default
template
> in this way means 'xref' is moved outside the (fig).  I have been told to
> override the default template with a predicate to not include <title> and
> use the default template to output the contents of <title>.
>



 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.