You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Scott N. Smith" <Sc...@HOTELINFOSYS.COM> on 2001/05/01 04:56:07 UTC

id(@var) always yields empty

I am always getting an empty string from the XPath id() function when I pass
in an attribute.

The DTD:
-------------------
<?xml version="1.0" encoding="UTF-8"?>

<!ELEMENT showproblem (foo|bar)*>
<!ELEMENT foo EMPTY>
<!ATTLIST foo
    ref IDREF #REQUIRED
>
<!ELEMENT bar EMPTY>
<!ATTLIST bar
    id ID #REQUIRED
>
-------------------

The XML:
-------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE showproblem SYSTEM "showproblem.dtd">
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="showproblem.xsl" type="text/xsl"?>
<showproblem>
  <bar id="barID"/>
  <foo ref="barID"/>
</showproblem>
-------------------

The XSL:
-------------------
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="showproblem">
            <html>
            <head>
                <title>Show My Misery</title>
            </head>
            <body>
                <xsl:apply-templates/>
            </body>
            </html>
    </xsl:template>
    <xsl:template match="foo">
        <p>The answer is <xsl:value-of select="id(@ref)/@id"/></p>
    </xsl:template>
</xsl:stylesheet>
-------------------

The desired result is: 'The answer is barID'.
The actual  result is: 'The answer is'.

I have beat on this for most of the day; looked at the XSL and Cocoon mail
lists, and I cannot see what I am doing wrong.  Can I use an attribute as an
id() argument as shown, or must it be constant?

Thanks in advance for anyone who can help this poor pathetic soul.

-Scott

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>