xsl-list
[Top] [All Lists]

Re: [xsl] fallback to a default template in xsl processing

2008-04-25 07:47:01
   <xsl:param name="ListName">
                        <xsl:value-of select="NAME"/>
   </xsl:param>

99 times out of 1000 when you use xsl:param or xsl:variable in thsi form
it's more efficient and more flexible to write
  <xsl:param name="ListName" select="NAME"/>

which defines $ListName to be the thing selected by NAME rather tahn a
result tree fragment with a root node and child text node with string
value the string value of the thing selected by NAME.


  <xsl:element name="table">
                        <xsl:element name="tbody">

I don't know why people use xsl:element so much, personally i would
always write that as

<table>
  <tbody>

which is easier to read. (It probably makes no difference at all to the
XSLT system though, so it is just personal preference)


                                <xsl:for-each select="node()">
you are steping through all nodes here including white space used for
indentation, comments and anything else. Except for eleemnts they woon't
have a name() so

  <xsl:element name="td">
   <xsl:value-of select="name()"/>
</xsl:element>

will be empty. I suspect that you only want to iterate through elements,
in which case change node() to *.

The first node under LIMS is always unique (i.e., the parent table),
the other nodes the child tables
so rather than the long xpath with the self:: tests I suggested had before, 
just do

<xsl:apply-templates select="*[1]" mode="parent"/>


then match on your parents, eg

<xsl:template match="SUBROUTINE" mode="parent">
something about subroutine, now handle the children
<xsl:apply-templates select="following-sibling::*" mode="child"/>
</xsl:template>

I don't know if that makes sense
you lost me around there, the list guidelines do suggest posting a
complete (small) input file and a complete (small) required result and a
complete (small) stylesheet attempt.

It's OK posting 2 or 3 (or even 10) line fragments of XSL as people can 
see what they do, but beyond that it's just noise and you need to post
complete well formed documents so people can actually run and/or modify
the code.

David





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