Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: What is an attribute such as dt:dt?

From: "Anthony Jones" <Ant@------------.--->
To: NULL
Date: 1/23/2008 11:37:00 AM

"tshad" <tfs@d...> wrote in message
news:e1wLfNYXIHA.1532@T......
> 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




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent