[xml] Legitimate xpath expressions in XSLT

Date view Thread view Subject view Author view

From: ross.alexander@uk.neceur.com
Date: Sun Feb 18 2001 - 12:13:56 EST


Hi,

I have the following problem with XSLT. Below is a fragment of the XML
and the XSL files with
the error.

<?xml version="1.0" encoding="ISO-8859-1"?>
<character>
  <skills>
    <skill name="Balance" base="dex" ranks="2" total="5" mod="3"/>
    <skill name="Bluff" base="cha" ranks="3" total="4" mod="1"/>
    <skill name="Climb" base="str" ranks="6" total="5" mod="-1"/>
    <skill name="Diplomacy" base="cha" ranks="2" total="3" mod="1"/>
    <skill name="Escape artist" base="dex" ranks="2" total="5" mod="3"/>
    <skill name="Gather info" base="cha" ranks="2" total="3" mod="1"/>
    <skill name="Hide" base="dex" ranks="2" total="5" mod="3"/>
    <skill name="Jump" base="str" ranks="4" total="3" mod="-1"/>
    <skill name="Listen" base="wis" ranks="2" total="3" mod="1"/>
    <skill name="Move silently" base="dex" ranks="2" total="5" mod="3"/>
    <skill name="Perform" base="cha" ranks="4" total="5" mod="1"/>
    <skill name="Ride" base="dex" ranks="4" total="7" mod="3"/>
    <skill name="Search" base="int" ranks="2" total="3" mod="1"/>
    <skill name="Sense motive" base="wis" ranks="2" total="3" mod="1"/>
    <skill name="Spot" base="wis" ranks="2" total="3" mod="1"/>
    <skill name="Swim" base="str" ranks="4" total="3" mod="-1"/>
    <skill name="Tumble" base="dex" ranks="3" total="6" mod="3"/>
    <skill name="Use rope" base="dex" ranks="2" total="5" mod="3"/>
  </skills>
</character>

-------------------------------------------------------------------------------

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

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

<xsl:template match="skills">
  <xsl:for-each select="./*">
    <xsl:value-of select="./@name"/>
    <xsl:text> </xsl:text>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

-------------------------------------------------------------------------------

<?xml version="1.0"?>
Balance Bluff Climb Diplomacy Escape artist Gather info Hide Jump Listen
Move silently Perform Ride Search Sense motive Spot Swim Tumble Use rope

-------------------------------------------------------------------------------

Which is fine, except that when I use the statement

  <xsl:for-each select="*">
    <xsl:value-of select="./@name"/><?xml version="1.0"?>
    <xsl:text> </xsl:text>
  </xsl:for-each>

Error xpath.c:5215: Invalid expression
*
^
Segmentation fault (core dumped)

Now, before libxslt came out I was using (and still do) use xalanj. Both
xalanj-1.2.2 and
xalanj-2.0.0 give the correct? result of listing all the skill names as
above.

So, which implementation is correct or is there ambiguity with the XPATH
spec.
Personally I think there is a problem with the spec. In the examples of
abbrevitated
location paths * is described as all element children of the context node
but in
more formal syntax I can find no reference for *.
Should select="*" be identical to select="node()"?

Many thanks

Ross Alexander

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sun Feb 18 2001 - 14:43:30 EST