xsl-list
[Top] [All Lists]

Re: xsd:import and namespaces

2003-04-24 07:27:50
Oops. I forgot to mention that there are multiple xsd:import tags in the source document. So what I need is a predicate that will choose the correct @schemaLocation based on the namespace of the xsd:element/@ref.

Thanks for the reply. Sorry about the confusion.

On Wednesday, April 23, 2003, at 11:59 PM, Sundar Shanmugasundaram wrote:

To access the value of schemaLocation,
use the following expression:

<xsl:variable name="schema" select="../xsd:import/@schemaLocation"/>

regards,
sundar

-----Original Message-----
From: Peter Moore [mailto:pmoore(_at_)umn(_dot_)edu]
Sent: Thursday, April 24, 2003 3:39 AM
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] xsd:import and namespaces


How can I get the value of schemaLocation from the xsd:element/@ref
attribute in the following XML Schema sample:

...
<xsd:schema ... xmlns:xxx="http://www.yo.com/example.namespace";>
<xsd:import namespace="http://www.yo.com/example.namespace";
schemaLocation="http://www.yo.com/example.xsd"/>
...
<xsd:element ref="xxx:SomeName"/>
...

My xsl looks something like this:

...
<xsl:template match="xsd:element[(_at_)ref]">
        <xsl:element name="{(_at_)ref}">
                <xsl:variable name="schema"
select="//xsd:import/@schemaLocation[../@namespace=???]"/>

                <xsl:apply-templates
select="document($schema)//element[(_at_)name=current()/@ref]"/>
        </xsl:element>
</xsl:template>
...

Am I on the right track? If so, what should replace the ??? in the
location path? If I remove the stuff between the xsl:element tags I get
the following output:

...
        <xxx:SomeName xmlns:xxx="http://www.yo.com/example.namespace"/>
...

So XSLT knows the namespace I want...I just don't know how to ask it.

Thanks.

BTW...I'm using LibXSLT and perl for the transform.


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

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



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



<Prev in Thread] Current Thread [Next in Thread>