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

Re: Printing all child bachelor nodes

Subject: Re: Printing all child bachelor nodes
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Thu, 9 Feb 2006 09:59:53 -0600
xsl print node
On 2/9/06, Douglas F Shearer <dougal.s@xxxxxxxxx> wrote:
> I have one more query, is there anyway I could have ONLY the beds in
> bold?
>

If you need to start treating some children in different fashions I'd
recommend a mode approach...something like

<xsl:template match="features">
<xsl:apply-templates mode="pretty-print" />
</xsl:template

<xsl:template match="*" mode="pretty-print">
     <xsl:for-each select="@*">
               <xsl:value-of select="concat(' ', name(), ':', .)"/>
               <xsl:if test="position() != last()">,</xsl:if>
       </xsl:for-each>
       <xsl:text>.</xsl:text>
</xsl:template>

<xsl:template match="bed" mode="pretty-print">
<b>
     <xsl:for-each select="@*">
               <xsl:value-of select="concat(' ', name(), ':', .)"/>
               <xsl:if test="position() != last()">,</xsl:if>
       </xsl:for-each>
       <xsl:text>.</xsl:text>
</b>
</xsl:template>

You could further refactor that and have a call-template and yank out
that common code...ie
<xsl:template match="*" mode="pretty-print">
<xsl:call-template name="printAtt">
<xsl:with-param name="node" select="." />
</xsl:template>



<xls:template name="printAtt">
<xsl:param name='node' />
     <xsl:for-each select="node/@*">
               <xsl:value-of select="concat(' ', name(), ':', .)"/>
               <xsl:if test="position() != last()">,</xsl:if>
       </xsl:for-each>
       <xsl:text>.</xsl:text>
</xsl:template>

and so on.  (And hopefully replace that <b> with a span or something
with class info).

Jon Gorman

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.