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 August 11th, 2004, 05:21 PM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default attribute namespace prefix

hi all,

I have a question concerning XPath and the use of namespace prefix to target attributes.

Consider the following XML excerpt:

<?xml version="1.0" encoding="UTF-8"?>
<object xmlns="urn:foo:ob" xmlns:it="urn:foo:it" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<item param="value1" it:param="value2"/>
...
</object>

How can I target the param attribute (of the urn:foo:ob NS) by means of an XPath 1.0 and XPath 2.0 expression? Note that I am not interested in the param attribute in the urn:foo:it NS.

As far as I know, XPath 1.0 does not support namespace prefixes to address attribute nodes. Can this be solved in another way? Does XPath 2.0 support the use of prefixes to target attributes?

many thanks in advance
kind regards
thomas







 
Old August 12th, 2004, 06:01 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Attribute names must be prefixed if you want them in a namespace so you don't need to worry about the overall default namespace. You will need to set up a dummy prefix in your XSLT if you wish to search on elements though.
If your prefix were to be "myNS" then the path would be:

/myNS:object/myNS:item/@param

See

http://p2p.wrox.com/topic.asp?TOPIC_...ault,namespace

Joe (MVP - xml)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove namespace prefix from XmlBean ratzko BOOK: Professional Java Development with the Spring Framework 0 August 10th, 2008 01:23 PM
Adding Prefix and Namespace to XML Lerxt XSLT 6 November 8th, 2007 03:14 PM
Prefix Data bundersuk Access VBA 2 December 26th, 2006 06:10 PM
How a additional prefix in a namespace comes? diang BOOK: ASP.NET Website Programming Problem-Design-Solution 0 July 13th, 2006 10:40 PM
change namespace leaving prefix unchanged lantoli XSLT 3 June 26th, 2006 07:31 AM





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