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 July 23rd, 2013, 08:57 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Default Working with XML in different namespaces

Hi,

I have an XML file which has a root element with different namespace like below:
Code:
<test xmlns:aaa="http://software.tx.aaa"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://software.tx.com/nmitl1"
     xmlns:nmi="http://software.tx.nmiforms.com/a"
     xmlns:nmiTable="http://software.tx.nmitable.com/b"
     xmlns:nmiTables="http://software.tx.nmitables.com/c"
     version="2.0"
     xsi:schemaLocation="http://software.tx.bbb.com/nmitl1 nmi.xsd">
And this tag consists of a child

Code:
<msg-set>
<input-msg>
          <TaskSets>
            <TaskSet xmlns="http://software.tx.nmiforms">Transport</TaskSet>
         </TaskSets>
</input-msg>
</msg-set>
How can i get the value of <TaskSet> from the above.

I've declared the namespaces in the stylesheet like
Code:
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" exclude-result-prefixes="nmirepo xsi nmi nmiTable nmiTables"xmlns:aaa="http://software.tx.aaa"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://software.tx.com/nmitl1"
xmlns:nmi="http://software.tx.nmiforms.com/a"
xmlns:nmiTable=http://software.tx./nmitable.com/b
xmlns:nmiTables=http://software.tx./nmitables.com/c
xsi:schemaLocation="http://software.tx.bbb.com/nmitl1 nmi.xsd" xpath-default-namespace="http://software.tx.com/nmitl1">
__________________
Rummy
 
Old July 26th, 2013, 05:21 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

In your stylesheet you have to bind a prefix to the namespace with e.g.

Code:
xmlns:nf="http://software.tx.nmiforms"
then you can select

Code:
<xsl:value-of select="//nf:TaskSet"/>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML documents with namespaces skipw BOOK: Expert PHP and MySQL 0 June 7th, 2012 12:13 PM
copy-namespaces attribute not working? ebaerwald XSLT 10 September 7th, 2010 11:10 AM
XML, Namespaces and XSLT, Oh, My! mphare XSLT 5 August 4th, 2010 02:27 PM
Confused about XML namespaces planoie XSLT 2 June 2nd, 2005 04:23 AM
XML Namespaces billy_bob_the_3rd XML 1 January 31st, 2005 03:41 PM





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