RE: [xsl] Need help to flatten and regroup data

Subject: RE: [xsl] Need help to flatten and regroup data
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Mon, 24 May 2004 20:19:05 +0200
> -----Original Message-----
> From: Yang, Siew-Hong [mailto:siew-hong.yang@xxxxxx]
>

Hi,

<snip what="source + target XML description" />
>
> I flatten the data but then I could not get anything else going. In
> particular, I could not make XSLT to use template that tries to match
> anything NOT in the "ns:" nodes. Examples, I could not get <template
> match="//Node"> or  <template match="//metric">to work....
>
> I declared the namespaces at the beginning of the style sheet.
>

Can you show us a bit more of the source document? Is it perhaps using
another namespace for the nodes without prefix? (And how exactly are the
namespaces defined in your stylesheet...?)

Try if

match="*[local-name()='Node']"

works. If it does, I guess the root node in the source document has
xmlns="_some namespace URI_" (?) If so, bind this namespace to another
prefix on the xsl:stylesheet element, and then use that prefix to select the
nodes that are without prefix in your source XML.

Normally, IIRC, XPath uses no-namespace (not even the default one), unless
explicitly asked to take this into account by specifying it like:

match="*[namespace-uri()='_some namespace URI_']"

or by matching nodes to their fully qualified name (incl. namespace prefix,
and that is, the prefix to which the namespace is bound in your
xsl:stylesheet element), or by doing something more ugly like:
starts-with(name(),'ns:') ('ugly' because of the dependency of this piece of
code on the namespace being bound to *that* particular prefix)


HTH!

Greetz,

Andreas

Current Thread