This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newbie: template match using a mix of namespace prefix and none p refix


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]