Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. help with XPath expression

help with XPath expression

Scheduled Pinned Locked Moved XML / XSL
xmldatabasecomregexhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Hodnick
    wrote on last edited by
    #1

    Here is my document: <data> <meetings> <meeting id="900" title="Meeting Title" date="1/1/2005" location="Main Office"> <attendee personID="100" /> <attendee personID="101" /> </meeting> </meetings> <people> <person id="100" firstname="John" lastname="Doe" /> <person id="101" firstname="Jane" lastname="Smith" /> <person id="102" firstname="Jack" lastname="Williams" /> </people> </data> I want to be able to display the meeting info, then display a table of meeting attendees. When displaying attendees, I want to match their related person info in a different node in the document. e.g. the desired output for the single meeting above would be: Meeting Title, Main Office, 1/1/2005 John Doe Jane Smith Here is how I'm approaching it: <xsl:template match="/data/meetings/meeting"> <xsl:for-each select="attendee"> <p> <xsl:value-of select="/data/people/person[@id=@personID]/@firstname" /> <xsl:value-of select="/data/people/person[@id=@personID]/@lastname" /> </p> </xsl:for-each> </xsl:template> The stylesheet loads fine, but there is no output for each person. If I hard-code the @personID value in the query I'm using to get to the specific person, then it works fine. Where am I going wrong? Michael Hodnick www.kindohm.com

    T 1 Reply Last reply
    0
    • M Mike Hodnick

      Here is my document: <data> <meetings> <meeting id="900" title="Meeting Title" date="1/1/2005" location="Main Office"> <attendee personID="100" /> <attendee personID="101" /> </meeting> </meetings> <people> <person id="100" firstname="John" lastname="Doe" /> <person id="101" firstname="Jane" lastname="Smith" /> <person id="102" firstname="Jack" lastname="Williams" /> </people> </data> I want to be able to display the meeting info, then display a table of meeting attendees. When displaying attendees, I want to match their related person info in a different node in the document. e.g. the desired output for the single meeting above would be: Meeting Title, Main Office, 1/1/2005 John Doe Jane Smith Here is how I'm approaching it: <xsl:template match="/data/meetings/meeting"> <xsl:for-each select="attendee"> <p> <xsl:value-of select="/data/people/person[@id=@personID]/@firstname" /> <xsl:value-of select="/data/people/person[@id=@personID]/@lastname" /> </p> </xsl:for-each> </xsl:template> The stylesheet loads fine, but there is no output for each person. If I hard-code the @personID value in the query I'm using to get to the specific person, then it works fine. Where am I going wrong? Michael Hodnick www.kindohm.com

      T Offline
      T Offline
      Tomas Petricek
      wrote on last edited by
      #2

      Hi, this tries to select person whose id is same as personID. (it would work with data like this: <person id="100" personID="100" firstname="John" lastname="Doe" />) You need to tell parser, that attribute personID is not atribute of person tag, but attribute of attendee tag. I'm not sure if I'm correct, but try something like this: <xsl:value-of select="/data/people/person[@id=./@personID]/@firstname" /> Hope this helps:)

      Tomáš Petříček (Microsoft C# MVP)
      www.eeeksoft.net | Asp.Net Graphical controls

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups