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 June 19th, 2008, 07:38 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default IF statement = select rendering

Trying to get XSLT to seek out templateID root and render the select statement. XSLT seems to ignore the if statement. Is there a better way to have the IF statement search the XML document and render the select value?

XSLT 2.0

<td width='50%' align='left' valign="top"><b><xsl:text>Occupation: </xsl:text></b>
<xsl:if test="//n1:templateId/@root='2.16.840.1.113883.10.20.1.15'">
<xsl:value-of select="/n1:ClinicalDocument/n1:component/n1:structuredBody/n1:component/n1:section/n1:entry/n1:observation/n1:value/@displayName"/>
</xsl:if>
</td>

 
Old June 19th, 2008, 07:54 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I suspect that you are overlooking the fact that a path expression starting with "/" or "//" always selects from the root of the document, so <xsl:if test="//x"/> tests if there is an <x> anywhere.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 19th, 2008, 08:07 AM
Authorized User
 
Join Date: Jun 2008
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Understood, however I only have root='2.16.840.1.113883.10.20.1.15' in one place in the XML document. If that is the case should the //x/ work? or should I be more specific because //templateID/@root is in other areas of the xml document? I have also tried to type out the whole path without the "If" statement correctly rendering the value. Thanks as always for your help!

 
Old June 19th, 2008, 09:47 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It is unclear what you are trying to display - basically the logic currently reads as follows:

If there exists, anywhere in my document an element called templateId with a root attribute that equals '2.16.840.1.113883.10.20.1.15' Then display the following attribute value.

This is likely because you are not considering the current context - a core concept of XSLT programming.

Without knowing the structure of your XML document (please don't post a whole HL7 document!) its hard to say what you are trying to output, nor how to display it.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Statement jmss66 VB How-To 7 August 20th, 2008 04:02 PM
Select Statement gregalb SQL Server 2005 3 May 16th, 2008 08:51 AM
select statement help... RinoDM SQL Server 2000 13 January 10th, 2008 08:34 PM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Select Statement jmss66 Oracle 1 May 27th, 2004 02:31 PM





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