473,386 Members | 1,694 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,386 software developers and data experts.

XSL and QNames

Hi,
i have an xml document like this:

<?xml version="1.0"?>
<qname:element id="blabla" xmlns:qname="http://myblabla.com">
<qname:child>My text</qname:child>
</qname:element>

[remark: i'm using QNames in my xml document]

Suppose i want to get the attribute 'id' from qname:element and the
value of the qname:child node, how should i do this with xsl?

i thought it would work just like other stylesheets, without taking into
account the qname, but it didn't work :(

Anyone a solution?

w.Kind regards
Pieter

Jul 20 '05 #1
2 1457
In article <10***************@seven.kulnet.kuleuven.ac.be>,
Pieter Vandepitte <pi***************@cc.kuleuven.ac.be> wrote:

% <?xml version="1.0"?>
% <qname:element id="blabla" xmlns:qname="http://myblabla.com">
% <qname:child>My text</qname:child>
% </qname:element>

% [remark: i'm using QNames in my xml document]

A QName is a combination of a name space and an element name. In your
example, `qname' is a name space prefix while qname:child is a QName.

% Suppose i want to get the attribute 'id' from qname:element and the
% value of the qname:child node, how should i do this with xsl?

You need to define a name space prefix in the stylesheet. For instance

<xsl:value-of select="bla:element/@id" xmlns:bla='http://myblabla.com'/>

You can, of course, define the name space prefix at a higher level.

It's worth mentioning that you must use a name space prefix in the
stylesheet, even if you use a default name space in your xml document.
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #2
thanx!! i was forgotten an xsl document IS an xml document, in which you
can use an xmlns 'name space prefix' ;)

Patrick TJ McPhee wrote:
In article <10***************@seven.kulnet.kuleuven.ac.be>,
Pieter Vandepitte <pi***************@cc.kuleuven.ac.be> wrote:

% <?xml version="1.0"?>
% <qname:element id="blabla" xmlns:qname="http://myblabla.com">
% <qname:child>My text</qname:child>
% </qname:element>

% [remark: i'm using QNames in my xml document]

A QName is a combination of a name space and an element name. In your
example, `qname' is a name space prefix while qname:child is a QName.

% Suppose i want to get the attribute 'id' from qname:element and the
% value of the qname:child node, how should i do this with xsl?

You need to define a name space prefix in the stylesheet. For instance

<xsl:value-of select="bla:element/@id" xmlns:bla='http://myblabla.com'/>

You can, of course, define the name space prefix at a higher level.

It's worth mentioning that you must use a name space prefix in the
stylesheet, even if you use a default name space in your xml document.


Jul 20 '05 #3

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

Similar topics

9
by: Chris Spencer | last post by:
Does anyone know how to make ElementTree preserve namespace prefixes in parsed xml files? The default behavior is to strip a document of all prefixes and then replace them autogenerated prefixes...
0
by: Tim Meagher | last post by:
I have an XSL transform that tries to set the schema definition of the root attribute as follows: <xsl:template match="CR"> <xsl:element name="CR"> <xsl:attribute...
4
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..."...
5
by: MoonStorm | last post by:
Hi guys, Please solve a puzzle I am trying to figure out for some time. Let's say I have a fragment stored inside a variable, for instance: <xsl:variable name="layoutSettings"> <module>...
6
by: David B. Bitton | last post by:
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribute with a namespace defined. If I attempt to deserialize the XML, I get...
0
by: matt | last post by:
I am writing a web service using the WSDL first method. The schema specified that an element called Types is a list of QNames. It expects the message representation of this to look like <Types...
4
by: mattx | last post by:
I've posted this before but no one seems to respond. I need to know if this is a bug I am implementing a webservice against a preexisting schema/wsdl The schema specifies an element called...
5
by: AdSR | last post by:
Hi, I'm having a problem with the Amara toolkit. Try this: >>> from amara import binderytools >>> raw = '<pq:test xmlns="http://example.com/namespace" xmlns:pq="http://pq.com/ns2"/>' >>> rwd...
3
by: 0to60 | last post by:
Please help! I'm using the following code to get an XML doc: string str = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=12345&city=addison"; System.Net.HttpWebRequest request =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.