René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
XSL: Reading attribute values | ||
The XML File:
<?xml version="1.0"?> <persons> <person><name>Alex </name><contact type='tel' >01 234 567</contact></person> <person><name>Bert </name><contact type='mobile'>98 765 432</contact></person> <person><name>Charlie</name><contact type='email' >c@def.qq </contact></person> <person><name>Dave </name><contact type='tel' >77 666 555</contact></person> <person><name>Emila </name><contact type='mobile'>e@fed.qq </contact></person> </persons>
The XSL File:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="person"> <br> <xsl:value-of select="name" />, <xsl:value-of select="contact/@type"/>: <xsl:value-of select="contact" /> </br> </xsl:template> </xsl:stylesheet>
The output (whitespaces manually modified):
<?xml version="1.0" encoding="UTF-8"?> <br>Alex , tel: 01 234 567</br> <br>Bert , mobile: 98 765 432</br> <br>Charlie, email: c@def.qq </br> <br>Dave , tel: 77 666 555</br> <br>Emila , mobile: e@fed.qq </br>
A similar example, but with persons having two contacts.
|