Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Processing IDREFS attributes

From: Dan Vint <dvint@--------->
To:
Date: 11/2/2005 12:03:00 AM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent