473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

XSL/XPath permitting different namespace prefixes

I'm fairly new to XSLT and XPath. My question is related to some posts
I found in group archives (e.g. "Disable XPath namespace matching in
XSL") but is a little more specific.

I want a single XSLT document to be able to process a documents in a
defined format which may or may not have its namespace delcared.

I know how to process either form of an element using
<xsl:apply-templates select="*[local-name() = 'my-root']"/>
or
<xsl:apply-templates select="my-root | pref:my-root"/>

The problem is that even with these statements it appears I still need
two separate mathing templates:
<xsl:template match="my-root>
...

<xsl-template match="pref:my-root">
...

I can get to a single template by calling the same match template from
each of the named templates above. However, with several dozen types
of elements to process, this becomes very tedious!

Does anyone have a better way? Specifically is there a way to just
make the entire XSLT disregard or strip a specific namespace, or else a
way to make apply-templates match either form and then call a named
template?

TIA,
Chris

Mar 28 '06 #1
1 1423
chriscorbell wrote:
is there a way to just
make the entire XSLT disregard or strip a specific namespace
Not anything resembling cleanly, no.
way to make apply-templates match either form and then call a named
template?


Is there are reason you can't do
<xsl-template match="my-root | pref:my-root">
to let that template recognize both cases?

But, strong personal opinion: Any time you're trying to ignore
namespaces, your system design is *EXTREMELY* broken. You're discarding
important semantic information. Make the users write properly namespaced
documents; catering to broken docs is just going to make their life
harder in the long run.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: 0wl | last post by:
Hi, I am trying to get the value of child from xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child DataType="String">Hellpppp</p:child></p:root>""" using...
3
by: Colin Green | last post by:
I have come across what seems like a failing in the .Net XML classes. Many people have posted requesting how to write an XPath query with namespace prefixes that works. The solution shown in all...
4
by: Gismo | last post by:
I have got file raport.rld which is an XML file generated by MS Reporting Services. The problem is: in this file are tags from two different namespaces ...
2
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
1
by: sobczyk.wojciech | last post by:
I have XML: <xml xmlns="http://abc"> <A t="ttt"></A> <B xmlns="http://qwerty"><X>aaaa</X></B> </xml> How to point node "B" with XPath without any changes in this xml?
14
by: Mikhail Teterin | last post by:
Hello! What's would be the syntax for a query, which would allow me to get only the elements with non-empty text-nodes? For example, from: <a><b></b></a> <c/> <d><e>meow</e></d>
2
by: A. W. Dunstan | last post by:
I'm trying to figure out how XPath expressions work, and how I can use them to extract data into a particular format. I can extract the data I want using an XPath expression, but not with an XSLT...
4
by: gimme_this_gimme_that | last post by:
This may be so easy no one responds. What is the XPath expression that fetches the value PPV - the PersistentTicket? The namespace thing is throwing me off. Thanks. <?xml version="1.0"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.