This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Templatized processing
- To: xsl-list <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Templatized processing
- From: owner-xsl-list at lists dot mulberrytech dot com (by way of MulberryTechnologies List Owner)
- Date: Tue, 28 Aug 2001 11:48:24 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
From: "Larry Mason" <larry.mason@i2.com>
To: <XSL-List@lists.mulberrytech.com>
Subject: Templatized processing
Date: Tue, 28 Aug 2001 08:39:21 -0500
I would like to process my XML document in a subseted, user driven mode. =
Given the following raw data
<data>
<record id=3D"1"><field1>field 1</field1><field2>field =
2</field2><field3> field 3</field3><field4> field 4</field4></record>
<record id=3D"2"><field1> field 1</field1><field2> field =
2</field2><field3> field 3</field3><field4> field 4</field4></record>
</data>
I would like to define a user "view" as such (format of next snippet is =
open to change)
<displayorder>
<field>field3</field>
<field>field2</field>
</displayorder>
which would extract only fields 3 and 2 and in that order vs document =
order.
Here are my attempts.
<xsl:template match=3D"record">
<TR><TD nowrap=3D"yes">record id=3D<xsl:value-of =
select=3D"@id"/></TD></TR>
<TR><TD nowrap=3D"yes">brute force method</TD>
<xsl:apply-templates =
select=3D"*[local-name()=3Dxt:node-set(document($customFile)/displayorder=
/field)[1]]"/>
<xsl:apply-templates =
select=3D"*[local-name()=3Dxt:node-set(document($customFile)/displayorder=
/field)[2]]"/>
<xsl:apply-templates =
select=3D"*[local-name()=3Dxt:node-set(document($customFile)/displayorder=
/field)[3]]"/>
</TR>
<TR><TD nowrap=3D"yes">subseted but in document order</TD>
<xsl:apply-templates =
select=3D"*[local-name()=3Dxt:node-set(document($customFile)/displayorder=
/field)]"/>
</TR>
<TR><TD nowrap=3D"yes">not working at all</TD>
<xsl:for-each =
select=3D"xt:node-set(document($customFile)/displayorder/field)">
need help here. I have trouble getting to the proper context
</xsl:for-each>
</TR>
</xsl:template>
<xsl:template match=3D"record/*">
<TD nowrap=3D"yes"><xsl:value-of select=3D"."/></TD>
</xsl:template>
=20
Next would be to make fewer calls to document !
TIA,
Larry Mason
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list