Hi,
I have an issue retreiving values where parent and child have same namespace. I am using xslt version 1.0 and evaluating using xmlspy.
I need to read the value of the
ItemId and
Price elements from the following
xml for each
Item:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<Header>
<MessageId>888</MessageId>
<Action>1</Action>
</Header>
<Body>
<MessageParts xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<PriceSim xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/items">
<Item class="entity">
<FromDate>2014-04-03</FromDate>
<ItemId>0000001</ItemId>
<Price>6.0000</Price>
</Item>
</PriceSim>
<Item class="entity">
<FromDate>2014-04-03</FromDate>
<ItemId>0000002</ItemId>
<Price>7.0000</Price>
</Item>
</PriceSim>
</MessageParts>
</Body>
</Envelope>
Using an 'apply-templates' or 'for-each' function, I can't read from the
PriceSim child of
MessageParts in the following
xslt:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:env="http://schemas.microsoft.com/dynamics/2011/01/documents/Message" xmlns:mp="http://schemas.microsoft.com/dynamics/2011/01/documents/Message" xmlns:ps="http://schemas.microsoft.com/dynamics/2008/01/documents/items" exclude-result-prefixes="xsl env mp ps">
<xsl:output method="text" encoding="utf-8" />
<xsl:param name="delim" select="','" />
<xsl:param name="quote" select="'"'" />
<xsl:param name="break" select="'
'" />
<xsl:template match="/">
<xsl:apply-templates select="./env:Envelope/env:Body/env:MessageParts" />
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
I have tried both
./env:Envelope/env:Body/env:MessageParts/
env:PriceSim
and
./env:Envelope/env:Body/env:MessageParts/
mp:PriceSim
But I can't get past the MessageParts element. Is this because
Envelope and
MessageParts share the same namespace?
How can I read from the child elements using xslt in this instance?
Thanks in Advance,