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

Re: Generating schema target namespaces from XSLT

Subject: Re: Generating schema target namespaces from XSLT
From: Dan Vint <dvint@xxxxxxxxxxxxxx>
Date: Fri, 08 Nov 2002 19:36:50 -0800
xslt target namespace
I was just now able to give this a try, but unfortunately it doesn't work. I wasn't exactly sure of all the changes that might have been needed so I tried the following for the first solution offered:

1) Created variable and copy-of as shown, no other changes
2) Same as above but removed default namespace declaration from stylesheet element
3) moved copy-of to location after attributes
4) moved copy-of before schema element


Do you have any other suggestions? I didn't try the other solution because I want to pass the namespace value into the stylesheet and not have to edit my stylesheet as this value changes.

This did at least confirm my suspicion that XSLT is missing a good mechanism to manage namespace generation.

..dan

At 08:13 PM 11/2/2002 +0000, Trevor Nash wrote:
Hi Danny,

>I can get the targetNamespace attribute set, but becasue the namespace has
>to be identified on the <stylesheet> attribute I can't use a parameter
>there to set this value to be the same - thus I have to hard code it.
>
I assume you are declaring the namespace on xsl:stylesheet so that it
gets declared on the generated xsd:schema?

If so, then the trick is to create a temporary node with the required
namespace derived from $target, and then copy the namespace node to
the output xsd:schema element.  This requires an extension function,
but I see you are already declaring the saxon namespace.

  <xsl:variable name="ns-node">
      <xsl:element name="ns-element" namespace="{$target}"/>
  </xsl:variable>

  <xsd:schema>
       <xsl:copy-of
select="saxon:node-set($ns-node)/ns-element/namespace::*[local-name()='']"/>
       <xsl:attribute
name="elementFormDefault">unqualified</xsl:attribute>
       <xsl:attribute
name="attributeFormDefault">unqualified</xsl:attribute>
       <xsl:attribute name="targetNamespace"><xsl:value-of
select="$target"/></xsl:attribute>
       <xsl:attribute name="version"><xsl:value-of
select="ACORD-XML-DOC/@version"/></xsl:attribute>

</xsd:schema>

Does that do what you want?

Alternatively, you could set the value of the targetNamespace
attribute from the xsl:stylesheet declaration by an expression like
   document('')/xsl:stylesheet/namespace::*[local-name()='']
i.e. doing away with the parameter.

Best regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271
email:     tcn@xxxxxxxxxxxxx


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.