[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Best practices


Subject: Re: [xsl] Best practices
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 19 Jan 2004 09:53:25 -0500

At 2004-01-19 15:24 +0100, SHEIKH Sajjad wrote:
In the following xml document, what is the best way to display 'id' and
'description' of element lln and 'name' of element N when
objname='Folder'?

Do you mean the way to address it in XPath? One way would be to set the context using for-each and then pick and choose what you need.


If you had prefixed text:

  <xsl:for-each select="lln[@objname='Folder']">
    <!--prefix stuff-->
    <xsl:value-of select="@id"/>
    <!--infix stuff-->
    <xsl:value-of select="@description"/>
    <!--infix stuff-->
    <xsl:value-of select="n/@name"/>
    <!--suffix stuff-->
  </xsl:for-each>

If you just wanted them grouped together, you could concatenate them with spaces (or not):

  <xsl:for-each select="lln[@objname='Folder']">
    <xsl:value-of select="concat( @id, ' ', @description, ' ', n/@name )"/>
  </xsl:for-each>

If you want to create an importable fragment with which you can specialize the processing of each of the elements by an importing stylesheet with overriding template rules:

  <xsl:for-each select="lln[@objname='Folder']">
    <!--prefix stuff-->
    <xsl:apply-templates select="@id"/>
    <!--infix stuff-->
    <xsl:apply-templates select="@description"/>
    <!--infix stuff-->
    <xsl:apply-templates select="n/@name"/>
    <!--suffix stuff-->
  </xsl:for-each>

Do you mean the way to display it in appearance? I like blue, myself.

I hope this helps!

........................ Ken

<ll>
 <lln id="123" objname="Folder" description="a folder" name="lln one
name">
  <n name="n one name"/>
 </lln>
 <lln id="131" objname="Folder" description="a folder1" name="lln one
name1">
  <n name="n one name1"/>
 </lln>
 <lln id="143" objname="Document" description="a folder2" name="lln one
name2">
  <n name="n one name2"/>
 </lln>
</ll>


--
North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15
-          (San Francisco, CA): 3-day XSLT/2-day XSL-FO 2004-03-22
Asia        (Hong Kong, China): 3-day XSLT/2-day XSL-FO 2004-05-17
Europe       (Bremen, Germany): 3-day XSLT/2-day XSL-FO 2004-05-24
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


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




Current Thread
Keywords