Hi,
I have used XSLT on-and-off for a few months and have made reasonable progress. However......, a new requirement within our business has meant that we now need to:[*]Use XSLT on 'Envelope' XML[*]Output in 'Text' format (Previously we have only used XML output)
These are files from the Microsoft Dynamics environment.
I use
XMLSpy Version 5 Release 3 to test and debug and have found that apart from simple root extract statments (i.e. '.'), the varibles I set for the 'Enveloped' XML are NOT being populated/identified.
The
XML version is
1.0
The following XML is an abbreviated sample of a larger file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/Message">
<Header>
<MessageId>{4C139}</MessageId>
<SourceEndpointUser/>
<SourceEndpoint>kwt</SourceEndpoint>
<DestinationEndpoint>WeighbridgeSite</DestinationEndpoint>
<Action>ListMovementDelivery</Action>
<RequestMessageId/>
</Header>
<Body>
<MovementDelivery xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/MovementDelivery">
<DocPurpose>Original</DocPurpose>
<SenderId>kwt</SenderId>
<VCTMovements class="entity">
<DlvMode>Road</DlvMode>
<HasClaim>No</HasClaim>
<RecId>4737150574</RecId>
<RecVersion>1</RecVersion>
</VCTMovements>
</MovementDelivery>
</Body>
</Envelope>
The XSLT that I have started (I realise that it is in very simple form at the moment - but it is at a TEST stage) is:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://schemas.microsoft.com/dynamics/2006/02/documents/Message">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:apply-templates select="Envelope/Header" />
</xsl:template>
<xsl:variable name="FindIt" select="/Body/MovementDelivery/SenderId"/>
<xsl:variable name="FindIt2" select="//Body/MovementDelivery/DocPurpose"/>
<xsl:template match="Header">
<xsl:value-of select="./SourceEndpoint"/>
</xsl:template>
</xsl:stylesheet>
The output file just reads the whole file:
[code<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://schemas.microsoft.com/dynamics/2006/02/documents/Message" version="1.0"><xsl:output method="xml"/><xsl:template match="/"><xsl:apply-templates select="Envelope/Header"/></xsl:template><xsl:variable name="Entcnt" select="count(//Body/VCTMovements[@Class='Entity'])"/><xsl:variable name="FindIt" select="//Body/MovementDelivery/SenderId"/><xsl:variable name="FindIt2" select="//Body/SenderId"/><xsl:template match="Header"><xsl:value-of select="SourceEndpoint"/></xsl:template></xsl:stylesheet>[/code]
It's probably a very simple explanation, but it's got me.
Has it got something to do with the namespace/schemas? We previously used 'http://www.w3.org/1999/XSL/Transform' to interpret the code, but if I use it in the context of this file, the output file is blank.
Thanks in advance,
Neal
Neal
A Northern Soul