[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xsl:key

Subject: xsl:key
From: Rhonda Fischer <rhonda@xxxxxxxxxxxxxx>
Date: Thu, 22 Jun 2000 08:57:01 +0000
rhonda fischer
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.