473,406 Members | 2,371 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.

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 2817

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: 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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.