RE: [xsl] Transferring xmlns aliases to result tree.

Subject: RE: [xsl] Transferring xmlns aliases to result tree.
From: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Fri, 6 Jun 2003 19:23:00 -0500
OK, Tom, I understand better now what you're asking...
(It was late when I read your question last night.)

> Sure, here's the definition.
> 
> <wsdl:definitions targetNamespace="http://someurl/"; 
> xmlns="http://schemas.xmlsoap.org/wsdl/"; xmlns:impl="http://someurl/";>

This may be irrelevant, but I'm curious why you use the prefix
wsdl: but don't declare it.  Since this is the "top" of the
document, it's not inherited from above.  Unless that 'xmlns=' is 
supposed to be 'xmlns:wsdl='.

Also, just to check, you do intend targetNamespace to be an attribute,
right, not an actual namespace prefix declaration?

Another question: is this the input document or the output?

> So, the problem is that someType is defined within the WSDL 
> document as
> 
> <complexType name="someType">
> </complexType>
> 
> so it ends up being defined in targetNamespace, which is 
> equivalent to the impl namespace. This type is later used by 
> the line I gave before.

I'm afraid I'm lost... I don't know anything about WSDL,
so if that's a requirement, I'm not going to be much help to you.

> <element name="someElement" type="impl:someType"/>
> 
> and is referred to as impl:someType. What I meant when I said 
> "appears as text" is that "impl" is only used withing the txt 
> value of the type attribute. It's never explicitly used in 
> the name of an element or the name of an attribute.

So... why do you need the impl prefix to be declared,
if it never gets used?
If, as you say, it's used only within the value of an attribute,
where doesn't interact with namespace rules, why do you want
a namespace node for it?

Anyway, one thing you might try, if it's possible, is to put
an impl:dummy element or attribute into your result tree whose namespace
is "http://someurl";, to force a declaration of the impl: prefix.
I guess the tricky part might be getting it to have the scope you
need... but I have no idea what scope you'd need since I can't
see why you'd need one at all.

> Hence, it 
> is never evaluated by the xslt engine, and the namespace 
> alias is not copied into the result tree.
> 
> I have tried the following.
> 
> <xsl:for-each select="namespace::*">
> 	<xsl:copy/>
> </xsl:for-each>
> 
> But, it does not work very well, since the attribute will be 
> copied over as 'impl="http://someurl/";' and not as 
> 'xmlns:impl="http://someurl/";'.

This I don't understand at all.  What was the output when you
tried the above?  (And what was the input?)

A namespace node, copied
by <xsl:copy />, should produce a namespace node in the result
tree, not an attribute node.
Whether that namespace node gets serialized (into xmlns:impl="http://someurl/";)
or gets ignored may depend on whether an ancestor node
has the same prefix bound to the same namespace URI.

Maybe it would help to show more of your input XML
(clearly labeled as such) and your desired output,
and the XSL you're currently using.

HTH.  Miracles do happen.  :-)

Lars

> -----Original Message-----
> From: Lars Huttar [mailto:lars_huttar@xxxxxxx]
> Sent: Friday, June 06, 2003 12:40 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Transferring xmlns aliases to result tree.
> 
> 
> > I am having trouble transferring the xml namespace aliases 
> > from a source tree to the result tree. Specifically I would 
> > like to transfer some aliases that are used only within the 
> > value of an attribute.
> > 
> > <element name="someElement" type="impl:someType"/>
> > 
> > I have a mapping at the top of the document for impl, but 
> > it's not used anywhere else except the type attribute. Is 
> > there a way to force this mapping to appear in the result 
> > tree? It does not seem to be transferred. I assume it's 
> > because it appears as text.
> 
> What do you mean, it appears as text?
> 
> Can you show us your declaration of the "impl" prefix
> at the top of the document?
> 
> Lars


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


Current Thread