RE: Problem with id(@attrib)

Subject: RE: Problem with id(@attrib)
From: "Blanchette, Larry" <Larry.Blanchette@xxxxxxxxxxxxx>
Date: Thu, 18 Mar 1999 12:02:54 -0600
John, 

using:
	select="id(@product)/@name"/>
instead of 
	select="//id(@product)/@name"/>
seems to to the trick under xslp

I guess the logic is // selects descendents from instead of chidlren
from. If id(@product) evals to the product element it would be the 
same as //product/@name.  

larry

-----Original Message-----
From: John_Velonis@xxxxxxxxxxxx [mailto:John_Velonis@xxxxxxxxxxxx]
Sent: Thursday, March 18, 1999 9:28 AM
To: xsl-list@xxxxxxxxxxxxxxxx
Subject: Problem with id(@attrib)





Hi all,

I'm trying to convert the following XML to HTML using XSL:

<?xml version="1.0"?>

<vendors>

  <org name="Organization 1">
     <builds product="p1"/>
     <builds product="p2"/>
  </org>

  <org name="Organization 2">
    <builds product="p3"/>
  </org>

  <product id="p1" name="Product1">
  </product>

  <product id="p2" name="Product2">
  </product>

  <product id="p3" name="Product3">
  </product>

</vendors>

Here's my XSL stylesheet.  I'm new to XSL, so it may be kind of klunky,
but according to the spec it looks like it should work:

<?xml version="1.0"?>

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/TR/WD-xsl";
  xmlns="http://www.w3.org/TR/REC-html40";
  result-ns="">

  <xsl:id attribute="id"/>

  <xsl:template match="vendors">
    <HTML>
      <BODY>
        <H1>Organizations</H1>
        <xsl:apply-templates select="org"/>
        <HR/><H1>Products</H1>
        <xsl:apply-templates select="product"/>
      </BODY>
    </HTML>
  </xsl:template>

  <xsl:template match="org">
    <HR/><H2><xsl:value-of select="@name"/></H2>
    <xsl:if test="builds"><H3>Products</H3><UL>
      <xsl:apply-templates select="builds"/></UL></xsl:if>
  </xsl:template>

  <xsl:template match="builds">
    <LI><A HREF="#{@product}"><xsl:value-of
select="//id(@product)/@name"/></A></LI>
  </xsl:template>

  <xsl:template match="product">
    <HR/><H2><A NAME="#{@id}"><xsl:value-of select="@name"/></A></H2>
  </xsl:template>

</xsl:stylesheet>

The problem I'm having is with the "//id(@product)/@name" selection in the
"builds"
template.  LotusXSL returns nothing for this:
   <A HREF="#p1"></A>
XSL:P does better, but it includes all three products, not just the one with
the
specified id:
   <A HREF="#p1">Product1Product2Product3</A>

Is this valid usage?  Is there some other way to do this?  It seems like a
simple
task, but I haven't seen this exact situation in any examples.

John Velonis
Hyperion Solutions



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread