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

Re: namespaces problem - two transformations in one s

Subject: Re: namespaces problem - two transformations in one stylesheet possible?
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Mon, 6 Feb 2006 13:19:52 +0000
andrew ballantine
On 2/6/06, Andrew Ballantine <andrew.ballantine@xxxxxxxxxxxxxxx> wrote:
> Hi there,
>
> I have a problem with (unqualified) namespaces in the xml to be transformed
that is preventing a transformation from working. I understand that is is
possible to use a transformation to remove the namespaces, and then the result
of this can then be transformed. However the architecture that we are using
does not make it easy to use two stylesheets where one would normally have
been expected.
>
> Can I ask if it is therefore possible either to perform two transformations
on the one stylesheet (i.e. to transform the incoming xml, and then transform
the result of this first transformation), or alternatively is it possible to
reference a second stylesheet in the first and then pass the result of the
first stylesheet to a second one?
>
> A code example:
>
> Incoming message (I have no control over this):
>
> <?xml version="1.0" encoding="UTF-8"?>
> <message xmlns="http://www.valid_url.com">

elements are in this namespace ^^^^^^^^^^^^^^^^^^^^^^^


>         <m_control>
>                 <various_control_tags />
>         </m_control>
>         <m_content>
>                 <b_control>
>                         <various_other_control_tags />
>                 </b_control>
>                 <message_contents />
>         </m_content>
> </message>
>
> The existing stylesheet is something like the following:
>
> <xsl:stylesheet version="1.0"
xmlns:userDefined="http://mycompany.com/mynamespace"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="msxsl" extension-element-prefixes="userDefined">
>         <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
>         <xsl:template match="/">
>                 <xsl:apply-templates select="message"/>
>         </xsl:template>
>         <xsl:template match="message">
>                 <xsl:apply-templates select="m_content"/>
>         </xsl:template>
>         <xsl:template match="m_content">
>                 <quotation dtd-version="1.0">
>                         <versn>2.0</versn>
>                         <xsl:call-template name="control"/>
>                         <!-- assorted other templates -->
>                 </quotation>
>         </xsl:template>
>         <!--  Quotes/control -->
>         <xsl:template name="control">
>                 <!-- etc lots more xsl here -->
>         </xsl:template>
> </xsl:stylesheet>
>
> As stated the stylesheet does not like the namespace and fails to transform
as expected, and we are currently very limited by our architecture as to what
we can do about this. Any help or advice with this is much appreciated.

You haven't defined the namespace in your stylesheet - you won't be
able to match any elements in that namespace until you define it and
give it a prefix, and then adjust your match patterns:

<xsl:stylesheet xmlns:msg="http://www.valid_url.com"  ...>

and

<xsl:template match="msg:message">

As far as I can see that's all your problem is... no need for two passes.

cheers
andrew

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.