From the course: XML Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Conditional logic

Conditional logic - XML Tutorial

From the course: XML Essential Training

Start my 1-month free trial

Conditional logic

- One of the more powerful capabilities of XSLT is the ability to apply style sheet templates based upon the values of the incoming XML data. And that's what we're going to look at in this example. So let's open up conditional_logic.xml and also open conditional_logic.xslt So this is the same XML file that we've been using previous example. So there's an items root tag and it has a collection of item tags underneath it. And the contents of the XSLT style sheet should start to look familiar by now. So this is the xsl:for-each tag I introduced in the previous exercise. And there's a select statement here which is using an xpath expression to match all the item tags in the document. So what we're going to do is apply some conditional logic to the data. So the appearance of each item in the output will look slightly different based upon the data in the source. So I'll add some code for that. What I'm going to do is use the xsl:if tag to do this. And that comes along with a test attribute.…

Contents