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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL:if

Status
Not open for further replies.

Bell1991

Programmer
Aug 20, 2003
386
US
I am in the process of learning XML an XSL - my question is - is there a way to say if there is a value in an element to stop reading it - and start with the new record? Does that make senese?

<root>
<name></name>
<adress></address>
<city></city>
<state></state>
<zip></zip>
</root>

So, for example in city = Chicago - stop reading and don't display this record - show an error message and then continue reading the next record.

Thanks in advance,
-Bell
 
There is an 'if'-statement, there is also a 'choose' tag, works something like 'select case'. Look 'em up in any index.
In general, you don't 'stop reading' or 'start with another record': you define how any node should be handled.

In this example you parse any 'person' node:

<root>
<person>
<name></name>
<adress></address>
<city></city>
<state></state>
<zip></zip>
</person>
<person>
<etc/>
</person>
</root>

<xsl:template match=&quot;person&quot;>
<xsl:choose>
<xsl:when test=&quot;city='Chicago'&quot;>
<xsl:text>I don't like Chicago</xsl:text>
</xsl:when>
<xsl:eek:therwise>
<!-- do whatever -->
</xsl:eek:therwise>
</xsl:choose>
</xsl:template>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top