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

msxsl:node-set with default namespace

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>
<size>345</size>
<title>whatever</title>
</module>
</xsl:variable>

My standard namespaces look like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">

The node-set function behaves as expected.
The trouble appears when I try to add a default namespace to the
xsl:stylesheet declaration. A
select="msxsl:node-set($moduleSettings)/module/size" will return
nothing.

Jul 20 '05 #1
5 2816

The node-set function behaves as expected.
The trouble appears when I try to add a default namespace to the
xsl:stylesheet declaration. A

This behaviour is nothing to do with node-set() you will see the same
behaviour if you add a namespace to a source document. unprefixed
element names in XPath 1 _always_ refer to elements in no-namespace.

By adding a default namespace the elements in your variable are now in
that namespace.

Either you have to prefix the names in the Xpath or add xmlns="" to the
xsl:variable so the elements within it are in no-namespace.

David
Jul 20 '05 #2

Yes, you are right. Now it works.

However, from what I understand and tested, I cannot prefix the names in
xpath with the default namespace. If I choose this option, I have to
declare a new namespace and include the elements in that namespace. Am I
right?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Cody Amor <mo*******@gmail.com> writes:
Yes, you are right. Now it works.

However, from what I understand and tested, I cannot prefix the names in
xpath with the default namespace. If I choose this option, I have to
declare a new namespace and include the elements in that namespace. Am I
right?


you need to declare the same namespace twice with and without a prefix

<xsl:stylesheet xmlns="wibble" xmlns="w:wibble" ....

Now a literal result element of
<foo> is foo in wibble namepsace (as is <w:foo> ) and an Xpath of
//x:foo will find foo in the wibble namespace (whether or not it was
prefixed in the source)

David
Jul 20 '05 #4
Brrrrr, yes, it works. Thanks a lot.
Hopefully the standard will evolve in a more friendly way.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
Cody Amor <mo*******@gmail.com> writes:
Brrrrr, yes, it works. Thanks a lot.
Hopefully the standard will evolve in a more friendly way.


Yes it will, XSLT2 draft (which is already implemented in, eg, saxon8.x)
allows you to specify a default namespace for element names in Xpath
expressions, so you could keep everything unprefixed, and just use the
default namespace, then also declare that unprefixed xpath names refer
to that.

http://www.w3.org/TR/xslt20/#unprefixed-qnames

David
Jul 20 '05 #6

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

Similar topics

0
by: Carl | last post by:
Hi, I have found a way to map attributes (columns) to column headings. But this runs really slow. Is there a way to improve it? Thanks, Carl <?xml version="1.0" encoding="utf-8" ?>...
2
by: jd | last post by:
Hi, I have an xsl as below. I am trying to loop using <xsl:for-each> and in the select attribute of <xsl:for-each> i am getting the nodeset from the external javascript function in the <CDATA>...
7
by: Michael | last post by:
Hi, I have a problem parsing XML file using XSLT stylesheet by using : using System.Xml; using System.Xml.XPath; using System.Xml.Xsl; // load Xsl stylesheet XslTransform myXslTrans = new...
2
by: amit L via DotNetMonster.com | last post by:
hi all. i've been trying to pass a nodelist (!=nodeset??) from my c# application to some xsl transform to use. the xsl code is as follows: <xsl:stylesheet version="1.0"...
1
by: Philipp Schumann | last post by:
Hi, I'm using .NET Framework 1.1 XSLT. Can anyone tell me why this works: <xsl:for-each select="$somenodelist"> <xsl:if test="ext:CheckCondition (@condition)">Bla</xsl:if> </xsl:for-each>
2
by: Maxim Kazitov | last post by:
Hi, Is it possible to call C# function inside XSLT ? Thanks, Max
2
by: Dave Londeck | last post by:
Given the following I am trying to get the worksheet and all of its table, rows and data so that I can then add the result it to a master xml file. This will allow me to accumlate several...
1
by: Shrek | last post by:
My xslt file contains a passed parameters <xsl;param name="Widths">70px,70px,70px,100px,100px</xsl;param> which I want to use to sets the widths of my table columns . when I create my...
3
by: =?Utf-8?B?R2F1cmF2?= | last post by:
Hello, I am using translate in my .xslt to remove the space like this: <xsl:for-each select=".//Illustration"> <xsl:value-of select="translate(./@illusName, ' ', '')"/> But this doesn't...
1
by: Joost van den Boom | last post by:
Hi all, I use XslCompiledTranform to transform one XML file into another. In my stylesheet I use the msxsl:node-set() function, so I have a namespace import in my stylesheet. After...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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,...

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.