Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old May 22nd, 2008, 06:22 AM
Friend of Wrox
Points: 696, Level: 9
Points: 696, Level: 9 Points: 696, Level: 9 Points: 696, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2006
Location: Ennis, Clare, Ireland.
Posts: 129
Thanks: 10
Thanked 0 Times in 0 Posts
Default Processing MS Dynamics XML Envelope


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:

<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/Message">
        <MovementDelivery xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/MovementDelivery">
            <VCTMovements class="entity">
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:variable name="FindIt" select="/Body/MovementDelivery/SenderId"/>
<xsl:variable name="FindIt2" select="//Body/MovementDelivery/DocPurpose"/>

††<xsl:template match="Header">
    <xsl:value-of select="./SourceEndpoint"/>

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,



A Northern Soul

A Northern Soul
Reply With Quote
  #2 (permalink)  
Old May 22nd, 2008, 06:48 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

You can't just 'redefine' the xsl prefix like that!

<?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/2006/02/documents/Message">
<xsl:output method="text" />
<xsl:template match="/">
    <xsl:apply-templates select="ENV:Envelope/ENV:Header" />

<xsl:variable name="FindIt" select="/ENV:Body/ENV:MovementDelivery/ENV:SenderId"/>
<xsl:variable name="FindIt2" select="//ENV:Body/ENV:MovementDelivery/ENV:DocPurpose"/>

  <xsl:template match="ENV:Header">    
    <xsl:value-of select="./ENV:SourceEndpoint"/>    
/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old May 22nd, 2008, 06:57 AM
mhkay's Avatar
Wrox Author
Points: 18,420, Level: 59
Points: 18,420, Level: 59 Points: 18,420, Level: 59 Points: 18,420, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,952
Thanks: 0
Thanked 289 Times in 284 Posts

Firstly, the namespace must be 'http://www.w3.org/1999/XSL/Transform' otherwise this is not an XSLT stylesheet at all.

Take a look at the first sticky post in this forum concerning the default namespace. You need to declare


and then use path expressions (and match patterns) like m:Envelope/m:Header. (And similarly for the MovementDelivery namespace).

Also note: /Body/MovementDelivery/SenderId won't find anything because Body isn't the outermost element.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing ENTITY and NOTATION lines in xml mrame XSLT 2 August 1st, 2008 02:24 PM
C#, Sharepoint, BDC, Dynamics GP10, Webparts NeilSc .NET Web Services 1 January 20th, 2008 03:34 PM
Need help on Processing two xml and updating one a sayanand XSLT 7 October 12th, 2007 06:35 AM
Fluid Dynamics with WPF : Error bhavsac Windows Presentation Foundation 0 July 17th, 2007 08:21 AM
Controlling Outgoing Custom XML Envelope Content RaminS Biztalk 1 June 12th, 2003 07:03 AM

All times are GMT -4. The time now is 03:26 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.