|
Subject: xsl:key From: Rhonda Fischer <rhonda@xxxxxxxxxxxxxx> Date: Thu, 22 Jun 2000 08:57:01 +0000 |
Howdy Jeni,
Thank you so much for your reply. It was very helpful.
My aim is to extract paragraphs from the source tree
(temp.xml) to be output to a result tree according to
two criteria:
* Target doc="contract" and
* Target host="true"
This is an extension of my original question.
The output I receive is all paragraphs disregardless
of attribute doc and host values. I have attempted
to achieve my goal using two methods. I hope that you/other
might be able to assist me.
Kind Regards
Rhonda
temp.xml (this I have changed so that Target is not empty)
-------
<Template>
<Target doc="contract">
<Target host="true">
<Para>This is a paragraph that will end up in a
contract with hosting customers</Para>
</Target>
</Target>
<Target doc="advice">
<Target host="true">
<Para>This is a paragraph that will end up in a
customer advice document for
hosting customers </Para>
</Target>
</Target>
</Template>
ATTEMPT 1: Using the Key() function
=============================
I realise that only one key value can be used and
then the other key value can be used on the filtered
result - unless the intersection saxon extension
function is used. However here I still receive
all paragraphs, it seems without referencing
the index created by my xsl:key?
<xsl:key name="blueprint" match="Para" use="../Target/@doc"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Para">
<xsl:element name="{name()}">
<xsl:copy-of select="key('blueprint', contract)"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
.......And then template to copy <Template>
I have also, since simply typed the value of contract
in the key, quotes do not seem to make any difference
either way.
ATTEMPT 2: Using a template match
============================
transform.xsl
----------
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
*** the following template is never used ***
*** and I did hope that this template would ***
*** select paragraphs according to attrib values ***
*** specified? ***
<xsl:template match='Para/Target[@doc="contract"
and @host="true"]'>
<xsl:element name="{name()}">
<xsl:copy-of select="attribute::node()"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="Template">
<xsl:element name="{name()}">
<xsl:copy-of select="attribute::node()"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: xsl:key, Jeni Tennison | Thread | Re: xsl:key, Jeni Tennison |
| RE: How is this part of the XSLT sp, Kay Michael | Date | RE: counter, Kay Michael |
| Month |