![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - What is an attribute such as dt:dt? [Thread Next] Re: What is an attribute such as dt:dt?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 | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
