Skip to Content
Special Edition Using XSLT
book

Special Edition Using XSLT

by Michael Floyd
January 2002
Intermediate to advanced
480 pages
11h 5m
English
Que
Content preview from Special Edition Using XSLT

Adding New Template Rules

The style sheets presented thus far have used <value-of> to retrieve the content of top-level elements and attributes. However, the XML document instance in Listing 2.1 also contains subelements, namely, the address element:

<invoice num=”2317” invoiceDate=”07-09-01”> 
    ... 
    <address> 
        <streetAddress>123 Fourth Street</streetAddress> 
        <city>Sometown</city> 
        <state>CA</state> 
        <zip>12345</zip> 
        <province /> 
        <country>USA</country> 
    </address> 
   ... 
</invoice> 

To retrieve the content from, say, <streetAddress>, you could assign a step pattern in the select attribute of a <value-of> element. That might look something like:

<xsl:value-of select="invoice/address/streetAddress" /> 

This approach works fine for this example because ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Special Edition Using XML, Second Edition

Special Edition Using XML, Second Edition

- et al. David Gulbransen
XML for Publishers

XML for Publishers

Keith Fahlgren

Publisher Resources

ISBN: 0789725053Purchase book