Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using XSLT to match XML element ID's?

Status
Not open for further replies.
Aug 9, 2010
3
US
Hi,

Just started learning XML/XSLT this week. Have the basics down, and I am stuck on how to match different element sets based on a shared UID between them.

So, I have exported a MS Project file as XML, and I am applying an XSLT file to it. The XSLT reads through each task and displays specific element values from that task into an html table. This works great when I am selecting data from the current element only. What I am trying to do is display Task1.Name based on element Task2.UID matching Task1.UID when I am processing Task2.

IS this enough information? Or should I post snippets of the XML and XSLT files?

Thanks
Tom

 
Such as, the first such task1's preceding task2 in context...
[tt] <xsl:value-of select="preceding-sibling::Task[UID=current()/UID]/Name" />[/tt]
 
That was very helpful. Here is the "catch"

Not all tasks are adjacent to each other (preceeding). That UID could be referencing any task in the list technically. I believe it will always be somewhere before it though, if that helps.

IS there any way to choose the task that matches the UID, regardless of its position before that current task?

Thanks
Tom
 
Just replace preceding-sibling::Task by preceding::Task.
 
No errors, but no values being populated. Here is my current select:

<xsl:value-of select="preceding::Task[UID=current()/UID]/ID" />

I have an if statement above it:
<xsl:for-each select="Project/Tasks/Task">
...
..


Is it possible I have something wrong in my preceding path?
 
>... I am applying an XSLT file to it. The XSLT reads through each task and displays specific element values from that task into an html table. [blue]This works great[/blue] when I am selecting data from the current element only.

>I have an if statement above it:
><xsl:for-each select="Project/Tasks/Task">

If you meant really that that "works great when...", then there is no reason for what I suggested not working. I can only deduce that that "did not work great" or at all.

Have you taken care of the (default) namespace Project is in? Add all xpath with namespace prefix for that namespace.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top