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

empty element sabotages xsl:key

Subject: empty element sabotages xsl:key
From: "Nick Ridout" <costempd@xxxxxxxxxx>
Date: Tue, 13 Feb 2001 17:26:35 -0500
nick ridout
Just wondered if anyone could explain this?  I was getting results with key
() that I couldn't understand, and after much hair-pulling decided to ask
here.  I deleted a bunch of lines from my input XML so it would be short
enough to post, and all of a sudden key() started working.  So I played
with it until I found an element that, when present, appeared to sabotage
<xsl:key>. Is it illegal for an attribute to be set to null?

<OUTSYSNUMBER CODE=""></OUTSYSNUMBER>

I admit to being backleveled.  I think I'm running Xerces 1.0.3 (Xalan.jar
and Xerces.jar that came with LotusXSL 1.0.1).

Thanks,
Nick Ridout

ps: I hope it's ok to jump in with this question, as I haven't followed
this list in a while.  I did look at DaveP's FAQ (very helpful) and made an
attempt to find something in the archives, but if this has come up before I
missed it.

===========================================
Here's the input XML (including the offending element):

<?xml version="1.0" ?>
<PRCDATA>
  <CONTRACTDATA>
    <COUNTRY CODE="649">649</COUNTRY>
    <AREA>R11</AREA>
    <OUTSYSNUMBER CODE=""></OUTSYSNUMBER>
  </CONTRACTDATA>
  <LINEITEM TYPE="SL">
    <SOURCE>GPE</SOURCE>
    <BCC>3L10</BCC>
  </LINEITEM>
  <LINEITEM TYPE="SL">
    <SOURCE>GPE</SOURCE>
  </LINEITEM>
</PRCDATA>

=======================================
Here's the XSL:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:key name="type" match="LINEITEM" use="@TYPE"/>

<xsl:template match="/">
  <xsl:apply-templates select="PRCDATA"/>
</xsl:template>

<xsl:template match="PRCDATA">
  <xsl:element name="root">

  <lineitems-by-key>
    <xsl:apply-templates select="key('type','SL')"/>
  </lineitems-by-key>

  <lineitems-by-pattern>
    <xsl:apply-templates select="LINEITEM[@TYPE='SL']"/>
  </lineitems-by-pattern>

  </xsl:element>
</xsl:template>

<xsl:template match="LINEITEM">
  <Type><xsl:value-of select="@TYPE"/></Type>
</xsl:template>

<xsl:template match="text()"/>

</xsl:stylesheet>

=======================================
Here's the output when the offending element is included:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <lineitems-by-key/>
    <lineitems-by-pattern>
        <Type>SL</Type>
        <Type>SL</Type>
    </lineitems-by-pattern>
</root>

========================================
Here's the output when I remove the offending element:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <lineitems-by-key>
        <Type>SL</Type>
        <Type>SL</Type>
    </lineitems-by-key>
    <lineitems-by-pattern>
        <Type>SL</Type>
        <Type>SL</Type>
    </lineitems-by-pattern>
</root>

==== END OF POST ===========================



 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.