Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Processing IDREFS attributes

From: "G. Ken Holman" <gkholman@-------------------->
To:
Date: 11/2/2005 3:53:00 AM
At 2005-11-01 16:08 -0800, Dan Vint wrote:



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.

That turns out to be irrelevant ... only the ID declarations are 
required.  The string or node set that you supply to the id() 
function can be anything.



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?

To add a space separator between each of the ID values ... without it 
your result tree would just get a string of concatenated letters.  I 
thought your intention was to report the unique ID values from the 
IDREF pointers.



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.

I can't fathom what is going on and why the @references is just being 
repeated ... that code should have given you the concatenated string 
values of the elements whose ID typed attribute has a value in the 
tokenized set of values of the @reference node.



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(.)"/>

That just supplies the value of the current node to the id() function 
for tokenization and lookup.  Any string or node can be passed to the function.



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.

I can't see why either ... are your referenced elements empty?  Do 
they perhaps have an echo of the id= value in the element content?



Anyway ... it sounds like you are up and running now.



. . . . . . . . . . . . Ken




--
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


transparent
Print
Mail
Digg
delicious
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