xsl-list
[Top] [All Lists]

Re: Printing all child bachelor nodes

2006-02-09 08:59:53
On 2/9/06, Douglas F Shearer <dougal(_dot_)s(_at_)gmail(_dot_)com> 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>