Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2014, 08:55 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Issue retreiving values where parent and child have same namespace

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="'&quot;'" />
<xsl:param name="break" select="'&#xA;'" />
<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,
__________________
Neal

A Northern Soul

Last edited by Neal; June 24th, 2014 at 09:01 AM..
 
Old June 24th, 2014, 09:26 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Have you tried ps:PriceSim by any chance?

There is not difference between env and mp prefixes (i.e. they refer to the same namespace) but the ps prefix refers to a different namespace.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
Neal (June 24th, 2014)





Similar Threads
Thread Thread Starter Forum Replies Last Post
having issue printing child values by comparing parents value eruditionist XSLT 4 January 7th, 2009 02:34 AM
parent child presentation db96s1 Beginning PHP 0 February 7th, 2006 06:19 PM
Parent - Child Combo babloo81 BOOK: Professional Jakarta Struts 0 April 27th, 2005 01:54 PM
Retreiving textbox values from datagrid ashish_26 General .NET 1 October 15th, 2004 11:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.