Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2008, 08:15 PM
hag hag is offline
Registered User
 
Join Date: Mar 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default extracting attribute value

XSLT novice request?

I am trying to extract an attribute value from a child element where the attribute values from its parent match an attribute value of a distant sibling. The value in the child element is a file path/name. The attributes in the other elements are identifiers. The end result needs to be an html file.

Here are the pertinent bits from the xml file:

<manifest identifier="CMD_0551402_M" version="1.0">
  <organizations>
    <organization identifier="CMD_0551403">
      <item identifier="CMD_0551405">
        <title>Lecture Notes</title>
        <item identifier="CMD_0551406" identifierref="CMD_0551407">
          <title>Lecture 1</title>
        </item>
        <item identifier="CMD_0551409" identifierref="CMD_0551410">
          <title>Lecture 2</title>
        </item>
      </item>
    </organization>
  </organizations>

  <resources>
    <resource identifier="CMD_0551404">
      <file href="properties_CMD_0551403.xml"/>
    </resource>
    <resource identifier="CMD_0551407">
      <file href="lecture01.html"/>
    </resource>
    <resource identifier="CMD_0551410">
      <file href="lecture2.html"/>
    </resource>
  </resources>
</manifest>


...and here's what I'm trying to do:

Find the value of organizations/organization/item/item/@identifierref
Find the value in resources/resource/@identifier that matches it
and plug the corresponding file/@href value into here:

<xsl:attribute name="href">
<xsl:value-of select="file/@href"/>
</xsl:attribute>

...with an end result in html of, for example:
<a href="lecture01.html">Lecture 1</a>


Any help much appreciated.
 
Old March 3rd, 2008, 03:16 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

<xsl:value-of select="resources/resource[@identifier=current()/organizations/organization/item/item/@identifierref]/file/@href" />

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting ancestor by providing the attribute eruditionist XSLT 6 September 9th, 2008 08:12 AM
Extracting a number range from tag attribute group maikm XSLT 6 August 25th, 2008 04:54 PM
Replace an attribute with another attribute georgemeng XSLT 8 June 10th, 2008 11:04 AM
Extracting Subset and Modifying Attribute fauster XSLT 1 September 6th, 2006 08:41 AM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.