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

Re: Trying to build a schema and add a namespace

Subject: Re: Trying to build a schema and add a namespace
From: Dan Vint <dvint@xxxxxxxxx>
Date: Wed, 20 Apr 2005 15:06:27 -0700
addnamespace xmlns
Ok this approach worked perfectly. The only difference from what I tried and this was how the variable definition was placed. I placed the variable definition inside the for-each loop and used the same element and saxon function trick but that didn't work. I got something about duplicate namespaces being defined.

If I understand this example, the result is one variable that contains multiple elements, these elements are made into a nodeset and then their namespaces are used to add them to the schema element.

I don' t have the code that failed any longer, but I'm curious if there seems to be any real difference in the approaches? Shouldn't both methods work? The only difference I see about what I tried vs what is here is that I did the additions piece meal (probably more overhead) but the results should have been the same. Barring a dumb coding error, is there anything that jumps out as to why my approach shouldn't have worked?

Thank you very much.

..dan

At 09:11 AM 4/20/2005, David Carlisle wrote:

  A revised stylesheet with one entry
  being for the default namespace (no prefix) would be useful.

Note that attributes have a different meaning for no-prefix than
elements, so to include that case you have to use element nodes rather
than attribute nodes to generate the namespaces, but basically it's as
before


<namespaces> <namespace prefix="xsd">schema ns</namespace> <namespace prefix="">defaulttns</namespace> <namespace prefix="yy">ACORD default URL</namespace> <namespace prefix="acord-doc">ACORD doc URL</namespace> <namespace prefix="jag">ACORD JAG URL</namespace> </namespaces>





<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                   version="1.0"
                   xmlns:saxon="http://icl.com/saxon"
                   exclude-result-prefixes="saxon"
             xmlns:xsd="schema ns"
             >
<xsl:output method="xml" indent="yes" />

<xsl:template match="/">

<xsd:schema>

<xsl:variable name="rtf">
<xsl:for-each select="/namespaces/namespace">
<xsl:variable name="x"><xsl:if test="string(@prefix)">:</xsl:if></xsl:variable>
<xsl:element name="{@prefix}{$x}foo" namespace="{.}"/>
</xsl:for-each>
</xsl:variable>
<xsl:copy-of select="saxon:node-set($rtf)/*/namespace::*"/>
</xsd:schema>


</xsl:template>
</xsl:stylesheet>


$ saxon ns2.xml ns2.xsl <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="schema ns" xmlns="defaulttns" xmlns:yy="ACORD default URL" xmlns:acord-doc="ACORD doc URL" xmlns:jag="ACORD JAG URL"/>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--------------------------------------------------------------------------- Danny Vint

Specializing in Panoramic Images of California and the West
http://www.dvint.com

voice: 510-522-4703

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.