Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > msxsl:node-set with default namespace

Reply
Thread Tools

msxsl:node-set with default namespace

 
 
MoonStorm
Guest
Posts: n/a
 
      03-07-2005
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-comslt">

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.

 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      03-07-2005

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
 
Reply With Quote
 
 
 
 
Cody Amor
Guest
Posts: n/a
 
      03-08-2005

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!
 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      03-08-2005
Cody Amor <> 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
 
Reply With Quote
 
Cody Amor
Guest
Posts: n/a
 
      03-08-2005
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!
 
Reply With Quote
 
David Carlisle
Guest
Posts: n/a
 
      03-08-2005
Cody Amor <> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default-default namespace and localname Max XML 2 08-01-2006 04:17 PM
ERROR CS0234: The type or namespace name 'DataAccessHelper' does not exist in the namespace 'BCC' (are you missing an assembly reference?) li.eddie@gmail.com ASP .Net 0 01-06-2006 11:31 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Reaching into the default namespace when using another namespace. Jason Heyes C++ 1 11-19-2004 02:36 AM
Help:Why can't I use namespace System.Web? It is said that this namespace doesn't exist. But it should exist. Èý¹â ASP .Net 1 07-29-2003 04:31 PM



Advertisments