[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: conditional namespaces

Subject: RE: conditional namespaces
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 14 Dec 2001 17:32:35 -0000
saxon xslt generate ns0
You've told the system what you want the local name and the namespace URI of
the attribute to be, but you haven't given any hints about what you want the
namespace prefix to be. So it has to make one up. Why do you imagine it
should choose "ns", of all possible names? If you want to influence the
prefix, write <xsl:attribute name="banana:{$attribute}"
namespace="{$namespace}">. Most processors will respect your wishes if they
can, though they aren't obliged to.

Mike Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of
> ronald heller
> Sent: 14 December 2001 16:32
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  conditional namespaces
>
>
> Hi there,
>
> We  are a bit puzzled by the results we get from saxon and
> xalan when we
> try to generate XML with a xslt file in which the attribute
> on the root
> element is a varaibel as well as it's value and the namespace.
>
> Consider the following:
> XML:
> <document>
>     <title>title</title>
>
>     <a>aaa</a>
> </document>
>
> XSLT:
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:variable name="attribute">type</xsl:variable>
> <xsl:variable name="value">gg</xsl:variable>
> <xsl:variable name="namespace">http://www.google.com</xsl:variable>
>
>     <xsl:template match="*">
>        <xsl:copy>
>        	<xsl:copy-of select="@*"/>
>        	<xsl:apply-templates />
>        </xsl:copy>
>     </xsl:template>
>
>     <xsl:template match="document">
>     <document>
>     	<xsl:attribute name="{$attribute}" namespace="{$namespace}">
>     		<xsl:value-of select="$value" />
>     	</xsl:attribute>
>
>     	<xsl:apply-templates/>
>     </document>
>     </xsl:template>
>
> </xsl:stylesheet>
>
> OUTPUT:
> <?xml version="1.0" encoding="UTF-8"?>
> <document xmlns:ns0="http://www.google.com" ns0:type="gg">
>     <title>title</title>
>
>     <a>aaa</a>
> </document>
>
> Why are these 0 characters there? We had exspected something like:
> <?xml version="1.0" encoding="UTF-8"?>
> <document xmlns:ns="http://www.google.com" ns:type="gg">
>     <title>title</title>
>
>     <a>aaa</a>
> </document>
>
> The result we get with msxml 4 is more or less the same only
> it's doesn;t
> generate a zero but a string "auto" or something.
> What's going on here?
>
> Any help is greatly appreciated.
>
> RH
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.