Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Basic XLST selecting Elements

Greetings,
I'm using XMLspy and having problems selecting any child nodes under my complex type element <DeliveryInfo>

Can anyone point out where im going wrong?
Im a complete newbie to XML, XSD and XSL.

Below are extracts from XML showing elements names and XSL showing my attempts to select the values.

Thanks
Rob

extract from XML file
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2007 (http://www.altova.com) by Rob W -->
<PODBatch xmlns="http://my-pod/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my-pod/namespace E:\DOCUME~1\Rob\Desktop\POD02.XSD">
<POD>
<DeliveryInfo>
<DeliveryNoteNo>DN012345</DeliveryNoteNo>
<DeliveryDateTime>01/11/07 10:35</DeliveryDateTime>
<DeliveryDrivername>Bill Egg</DeliveryDrivername>
<DeliveryDriverSignature>B.Egg</DeliveryDriverSignature>
<DeliveryStatus>In transit</DeliveryStatus>
</DeliveryInfo>

Full XSL file

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi ="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:my="http://my-pod.com/namespace">

<xsl:template match="/">
<html>
<Header>
<img src="http://i140.photobucket.com/albums/r13/robtyketto/truck-clipart-icon2_ys61.gif" align="left"/>
<h2>Proof-of-Delivery</h2>
<xsl:apply-templates select="//my:POD/DeliveryInfo"/>
<br></br>
<hr></hr>
</Header>
<body>
<h3>Sender:</h3>
<address>
Company<br />
Hersham Place<br />
Something Road<br />
Walton-on-Thames<br />
Surrey<br />
KT19 4ZZ<br />
</address>
</body>
</html>
</xsl:template>

<xsl:template match="my:POD/DeliveryInfo">
<strong>Deliver Note No: </strong>xsl:value-of select="my:DeliveryNoteNo"><br/><br></br>
</xsl:template>

</xsl:stylesheet>
[2575 byte] By [Robtyketto] at [2007-11-11 11:58:09]
# 1 Re: Basic XLST selecting Elements
Ive now got if finding my path by adding the "my:" identifiers.

Xpath matches the path and prints "Delivery Note No" but cannot find the element value (See below).

<xsl:template match="my:POD/my:DeliveryInfo">
<strong>Delivery Note No: </strong><xsl:value-of select="my:DeliveryNoteNo"/>
</xsl:template>

Any ideas?

Thanks
Rob
Robtyketto at 2007-11-11 23:28:15 >