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 September 14th, 2010, 04:22 AM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to select value of element

Hi,

I have some problems with selecting values of elements:
Here is a part of my input xml document:

************************************************** *******
<?xml version="1.0" encoding="UTF-8"?>
<NotifyShipment xsi:schemaLocation="http://www.B2Boost.com/oagis Overlay/B2Boost/BODs/NotifyShipment.xsd" xmlns:oa="http://www.openapplications.org/oagis/9" xmlns:clmIANAMIMEMediaTypes="http://www.openapplications.org/oagis/9/IANAMIMEMediaTypes:2003" xmlns:oacl="http://www.openapplications.org/oagis/9/codelists" xmlns:clm54217="http://www.openapplications.org/oagis/9/currencycode/54217:2001" xmlns:clm5639="http://www.openapplications.org/oagis/9/languagecode/5639:1988" xmlns:qdt="http://www.openapplications.org/oagis/9/qualifieddatatypes/1.1" xmlns:clm66411="http://www.openapplications.org/oagis/9/unitcode/66411:2001" xmlns:udt="http://www.openapplications.org/oagis/9/unqualifieddatatypes/1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema" releaseID="1.0" xmlns="http://www.B2Boost.com/oagis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<oa:ApplicationArea>
<oa:Sender>
<oa:LogicalID>81</oa:LogicalID>
<oa:TaskID>DESADV</oa:TaskID>
</oa:Sender>
<oa:Receiver>
<oa:LogicalID>2913</oa:LogicalID>
</oa:Receiver>
<oa:CreationDateTime>2010-07-01T00:00:00</oa:CreationDateTime>
<oa:BODID>XXXXX</oa:BODID>
</oa:ApplicationArea>
<?xml version="1.0" encoding="UTF-8"?>
<NotifyShipment xsi:schemaLocation="http://www.B2Boost.com/oagis Overlay/B2Boost/BODs/NotifyShipment.xsd" xmlns:oa="http://www.openapplications.org/oagis/9" xmlns:clmIANAMIMEMediaTypes="http://www.openapplications.org/oagis/9/IANAMIMEMediaTypes:2003" xmlns:oacl="http://www.openapplications.org/oagis/9/codelists" xmlns:clm54217="http://www.openapplications.org/oagis/9/currencycode/54217:2001" xmlns:clm5639="http://www.openapplications.org/oagis/9/languagecode/5639:1988" xmlns:qdt="http://www.openapplications.org/oagis/9/qualifieddatatypes/1.1" xmlns:clm66411="http://www.openapplications.org/oagis/9/unitcode/66411:2001" xmlns:udt="http://www.openapplications.org/oagis/9/unqualifieddatatypes/1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema" releaseID="1.0" xmlns="http://www.B2Boost.com/oagis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<oa:ApplicationArea>
<oa:Sender>
<oa:LogicalID>81</oa:LogicalID>
<oa:TaskID>DESADV</oa:TaskID>
</oa:Sender>
<oa:Receiver>
<oa:LogicalID>2913</oa:LogicalID>
</oa:Receiver>
<oa:CreationDateTime>2010-07-01T00:00:00</oa:CreationDateTime>
<oa:BODID>XXXXX</oa:BODID>
</oa:ApplicationArea>
************************************************** *******

And here is a part of my stylesheet:

************************************************** *******
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oa="http://www.openapplications.org/oagis/9" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<notifyshipment>
<header>
<documentid><xsl:value-of select="/NotifyShipment/oa:ApplicationArea/oa:Sender/oa:LogicalID"/></documentid>

************************************************** *******

The value of select do not come back with a value.... I think it have to do something with namespaces but don't no the problem here.

Can someone help me on this?

Thnks!

Robert van Gangelen
 
Old September 15th, 2010, 01:42 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Try with the below:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oa="http://www.openapplications.org/oagis/9" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="oa fo">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:apply-templates select="*[local-name() = 'NotifyShipment']" mode="NS"/>
</xsl:template>
<xsl:template match="*" mode="NS">
<notifyshipment>
<header>
<documentid><xsl:value-of select="oa:ApplicationArea/oa:Sender/oa:LogicalID"/></documentid>
</header>
</notifyshipment>
</xsl:template>
There could be a better solution that this.
__________________
Rummy
 
Old September 15th, 2010, 03:50 AM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi mrame,

You code works but I don't really understand it... But that has to do with my xsl knownledge~! Now I tried to select some value form a other element in the same xml document:

************************************************** *******
<?xml version="1.0" encoding="UTF-8"?>
<NotifyShipment xsi:schemaLocation="http://www.B2Boost.com/oagis Overlay/B2Boost/BODs/NotifyShipment.xsd" xmlns:oa="http://www.openapplications.org/oagis/9" xmlns:clmIANAMIMEMediaTypes="http://www.openapplications.org/oagis/9/IANAMIMEMediaTypes:2003" xmlns:oacl="http://www.openapplications.org/oagis/9/codelists" xmlns:clm54217="http://www.openapplications.org/oagis/9/currencycode/54217:2001" xmlns:clm5639="http://www.openapplications.org/oagis/9/languagecode/5639:1988" xmlns:qdt="http://www.openapplications.org/oagis/9/qualifieddatatypes/1.1" xmlns:clm66411="http://www.openapplications.org/oagis/9/unitcode/66411:2001" xmlns:udt="http://www.openapplications.org/oagis/9/unqualifieddatatypes/1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema" releaseID="1.0" xmlns="http://www.B2Boost.com/oagis" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<oa:ApplicationArea>
<oa:Sender>
<oa:LogicalID>81</oa:LogicalID>
<oa:TaskID>DESADV</oa:TaskID>
</oa:Sender>
<oa:Receiver>
<oa:LogicalID>2913</oa:LogicalID>
</oa:Receiver>
<oa:CreationDateTime>2010-07-01T00:00:00</oa:CreationDateTime>
<oa:BODID>XXXXX</oa:BODID>
</oa:ApplicationArea>
<DataArea>
<oa:Notify/>
<Shipment>
<ShipmentHeader>
<oa:Note type="Comment">BlaBla</oa:Note>
<oa:DocumentReference>
<oa:DocumentID>
<oa:ID>40886474</oa:ID>
</oa:DocumentID>

************************************************** *******

In you xsl you send me we read data form the applicationarea element. But i also want to read the documentid and this element is in the dataaera element. How can this be set up???

Thnks!

Robert





Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to get value of element RobertvG XSLT 0 September 14th, 2010 03:43 AM
adding options to a select element dymanicly StevesonD Javascript How-To 0 September 28th, 2006 09:53 AM
XSL select by child element value vivhost XSLT 3 May 21st, 2005 02:58 AM
select wildcard element names groovepapa XSLT 4 September 1st, 2004 08:12 AM





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