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 February 9th, 2004, 12:40 PM
gb gb is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Matching of attribute values

Hi,

I have a basic question of matching of attribute values:

If I have a document fragment:

<model>

 <enum name="ABC">
   <enunMember name="member1">
      <value>0</value>
  </enumMember>
   <enunMember name="member2">
      <value>1</value>
  </enumMember>
 </enum>

 <enum name="XYZ">
   <enumMember name="member5">
      <value>20</value>
  </enumMember>
   <enumMember name="member7">
      <value>22</value>
  </enumMember>
 </enum>

 <class>
  <attribute name="attr1">
   <datatype>
     <enumRef name= "ABC">
        <value>20</value>
     </enumRef>
   </datatype>
  </attribute>
 </class>

</model>

---------------------------------------------------------------------------------------------------

When processing an 'attribute', I want to dump out the type information of the referenced "enum". I am struggling with the syntax to find the related "enum" from the "enumRef" name in "attribute".

I'm using the following:

<xsl:template match="enumRef">
        <xsl:value-of select="@name"/>

    <xsl:apply-templates select="//enum[@name ='ABC']">
    <xsl:apply-templates select="//enum[@name='{attribute::@name}' ]">

        </xsl:apply-templates>
</xsl:template>


What is the correct syntax to match an element using an attribute ["name" in this case] generically?

many thanks,
gb
 
Old February 9th, 2004, 05:25 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I think you needf to use current node:
Code:
<xsl:template match="enumRef">
<xsl:apply-templates select="//enum[@name = current()/@name ]"/>    </xsl:template>
--

Joe
 
Old February 10th, 2004, 04:12 AM
gb gb is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe,

Thanks for this.

regards,
gb





Similar Threads
Thread Thread Starter Forum Replies Last Post
Matching Values between two ranges hood8jmark Excel VBA 2 May 2nd, 2008 09:55 AM
Matching values in Sheet1 to those in other sheet hood8jmark Excel VBA 1 May 1st, 2008 09:07 AM
two workbooks--matching values within kwik10z Excel VBA 0 November 29th, 2007 11:51 AM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
different values with the same attribute name srini XSLT 0 January 21st, 2004 05:21 AM





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