Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Tue, 22 Jan 2008 21:46:58 -0800,    group: microsoft.public.xsl        back       


What is an attribute such as dt:dt?   
I have an xml file that I am trying run an xsl sheet on that has attributes 
such as:
dt:dt
xmlns:dt

<binary xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64" 
format="jpeg">

But if I try to do something like:

  <value>
    <xsl:value-of select="@xmlns:dt"/>
  </value>

I get an error:

Prefix "xmlns" is not declared

How can I run my script and take out these 2 values?

Thanks,

Tom
date: Tue, 22 Jan 2008 21:46:58 -0800   author:   tshad

Re: What is an attribute such as dt:dt?   
U¿ytkownik "tshad"  napisa³ w wiadomo¶ci 
news:e1wLfNYXIHA.1532@TK2MSFTNGP04.phx.gbl...
> <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64" 
> format="jpeg">
> But if I try to do something like:
>  <value>
>    <xsl:value-of select="@xmlns:dt"/>
>  </value>

xmlns:dt is a namespace's declaration which will be prefixed (recognized) by 
"dt" prefix, but dt:dt is an attribute from 
"urn:schemas-microsoft-com:datatypes" namespace (because prefix "dt" points 
to that namespace)
-- 
td
xmlguru.net
date: Wed, 23 Jan 2008 08:38:02 +0100   author:   TOUDIdel

Re: What is an attribute such as dt:dt?   
"tshad"  wrote in message
news:e1wLfNYXIHA.1532@TK2MSFTNGP04.phx.gbl...
> I have an xml file that I am trying run an xsl sheet on that has
attributes
> such as:
> dt:dt
> xmlns:dt
>
> <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64"
> format="jpeg">
>
> But if I try to do something like:
>
>   <value>
>     <xsl:value-of select="@xmlns:dt"/>
>   </value>
>
> I get an error:
>
> Prefix "xmlns" is not declared
>
> How can I run my script and take out these 2 values?
>

It would help if we knew more about what you are trying to do.

The only way you could select the attribute dt:dt specifically would be if
you already know that the XML may contain names in the
urn:schemas-microsoft-com:datatypes namespace.

In which case you can add xmlns:dt="urn:schemas-microsoft-com:datatypes"
attribute to your xsl:stylesheet element in the XSLT.

Now you can select="@dt:dt" to get the value of that attribute.

However xmlns is a special case alias used only to declare a namespace and
its alias.  You can select the namespaces active on a element with this:-

  <xsl:for-each select="namespace::node()">
   <dd>
    <xsl:value-of select="name()" />
    <xsl:text>=</xsl:text>
    <xsl:value-of select="."/>
   </dd>
  </xsl:for-each>

That will list the aliases in use and the namespaces they map to for the
current element and its ancestors.  However to determine whether the current
node itself has the xmlns attribute that declares the namespace my be
possible but only with some very hairy looking predicates.

An alternative which may fit your as yet unknown objective is enumerate the
attributes of an element along with each attributes name and namespace:-

    <xsl:for-each select="@*">
     <dt><xsl:value-of select="name()" /></dt>
     <dd>Value: <xsl:value-of select="." /></dd>
     <dd>Namespace: <xsl:value-of select="namespace-uri()" /></dd>
    </xsl:for-each>





-- 
Anthony Jones - MVP ASP/ASP.NET
date: Wed, 23 Jan 2008 11:37:18 -0000   author:   Anthony Jones

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us