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

Re: Processing IDREFS attributes

Subject: Re: Processing IDREFS attributes
From: Dan Vint <dvint@xxxxxxxxx>
Date: Tue, 01 Nov 2005 16:08:15 -0800
Re:  Processing IDREFS attributes
below

At 02:23 PM 11/1/2005, you wrote:
*If* you have properly declared the id attributes, for my example they are called id=, something along the lines of:

<!ATTLIST foo id ID #IMPLIED>


Yes and I had the references defined as IDREFS #IMPLIED as well.



then you should be able to say:

  <xsl:for-each select="id(@references)/@id">
    <xsl:if test="position()>1"> </xsl:if>
    <xsl:value-of select="."/>
  </xsl:for-each>

A slight twist on this does what I wanted, which was to go find the element that has the ID:


  <xsl:for-each select="id(@references)/@id">
    <xsl:value-of select="id(.)"/>
  </xsl:for-each>

This produces the content of the element with the assigned ID. Without it, I just got the id value. I'm not sure why you have the position test, can you explain that?


With my original code with added context:
<xsl:templete match='foo'>
<xsl:for-each select="id(@references)">
        <xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

It didn't loop for one problem, so there was only a single output, instead of two values as I expected. The output was just the same value as my @references content.

In my original code I had this as well, trying to get to the content of the element referenced, but nothing was being output, so I used the current value just to see if anything was being looked up.

<xsl:value-of select="id(.)"/>



and it would report a space-separated list of unique token values (rather than just @references since that might have duplicates).

If you don't have a declaration of the attribute type, then id() has nothing to look up and will always return an empty node set.

Yep, had that problem covered.



I hope this helps, Dan.

Yes, once again you have come to the rescue. I sort of see why adding the /@id to the for-each select worked, but I don't know why mine didn't work or like you said didn't give me all the content.


..dan
---------------------------------------------------------------------------
Danny Vint

Specializing in Panoramic Images of California and the West
http://www.dvint.com

voice: 510-522-4703

When H.H. Bennett was asked why he preferred to be out
shooting landscapes rather than spending time in his portrait studio:

"It is easier to pose nature and less trouble to please."

http://www.portalwisconsin.org/bennett_feature.cfm

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.