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

Re: Newbie: template match using a mix of namespace pr

Subject: Re: Newbie: template match using a mix of namespace prefix and none p refix
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 9 Sep 2002 09:38:50 +0100
template match namespace
Hi Palmer,

> I have troubles finding a template match when the Xpath is
> consisting of mixed with and without namespace prefix.
> (It is an OAGIS 7.1 message based on XDR and not XSD if that matters...)
>
> 1) Absolute path, not working
> <xsl:template
> match="/msg/req/dta/SHOW_PO_007/DATAAREA/SHOW_PO/POHEADER/of:USERAREA/of:TRA
> NSMETHD" mode="copy">
>
> 2) A relative path not working
> <xsl:template match="///POHEADER/of:USERAREA/of:TRANSMETHD" mode="copy">

My guess would be that these paths aren't working because the msg,
req, dta, SHOW_PO_007, DATAAREA, SHOW_PO and/or POHEADER elements are
in a namespace in your XML document. Without seeing your source
document I can't tell, but this seems to be the most likely
explanation.

If you have a default namespace declaration in your source document
then you should have a similar namespace declaration in your XSLT
stylesheet, but one that associates that namespace with a prefix. You
should then use that prefix in your files. For example if you declare
it with the prefix 'oagis' then you should use:

<xsl:template match="oagis:POHEADER/of:USERAREA/of:TRANSMETHD"
              mode="copy">
  ...
</xsl:template>

> 3) This one is working, but now I may match POLINE tags as well...
> <xsl:template match="//of:USERAREA/of:TRANSMETHD" mode="copy">

This template will only match of:TRANSMETHD elements that are children
of of:USREAREA elements, so I don't understand why you say that it
might match POLINE elements as well.

Having '//' at the start of a pattern is always superfluous. The
match pattern:

  of:USERAREA/of:TRANSMETHD

does just the same thing as the match pattern:

  //of:USERAREA/of:TRANSMETHD

it's just in the latter pattern, as well as testing whether the
of:TRANSMETHD element has a of:USERAREA parent, you're testing whether
that of:USERAREA element is a descendant of the root node. Every
element in the document is a descendant of the root node, so there's
little point testing that.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.