473,785 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

My standard namespaces look like this:
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="ur n: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:n ode-set($moduleSett ings)/module/size" will return
nothing.

Jul 20 '05 #1
5 2846

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*******@gmai l.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:styleshe et 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*******@gmai l.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
2184
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" ?> <?xml-stylesheet type="text/xsl" href="stylesheet.xslt"?>
2
7215
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> section. This code works fine with MSXML4.0 parser. When I try to use .Net, it gives me error saying " The expression passed to this method should result in a NodeSet."
7
3391
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 XslTransform() ;
2
1839
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" exclude-result-prefixes="extern msxsl local xql" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:local="#local-functions" xmlns:xql="#xql-functions" xmlns:extern="urn:dottraffic:lnk">
1
350
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
4952
by: Maxim Kazitov | last post by:
Hi, Is it possible to call C# function inside XSLT ? Thanks, Max
2
6127
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 worksheets in a file. I also need a named range for each worksheet. I am not sure if XSLT can handle this or if I need to automate Excel for this.. The following code is not producing a result. XmlNamespaceManager nsmgr = new...
1
2511
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 table I make the following call. <tr> <th valign="bottom" width="{foo:GetWidth(0)}">Length<br/>(units)</th>
3
1414
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 seem to work when i use the Transform() of .NET. The above works well with command line msxsl and XMLSpy.
1
3418
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 transforming, the root node of my resulting XML file has an attribute xmlns:msxsl="urn:schemas-microsoft-com:xslt"
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10153
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10093
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.