cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From solprovi...@apache.org
Subject Re: Can't match elements with colons
Date Fri, 11 Jul 2008 20:59:16 GMT
On 7/11/08, Jeff Schmitz <jeffandmonica@mac.com> wrote:
> Hello,
>    I'm trying to take the output of the CSVGenerator and transform it.
> However, my xslt will not match any of the elements that have colons in
> them.
>
> e.g. for the following xml generated by CSVGenerator:
>
> <?xml version="1.0" encoding="ISO-8859-1"?><relex
> xmlns:cinclude="http://apache.org/cocoon/include/1.0">
>   <systems><csv:document
> xmlns:csv="http://apache.org/cocoon/csv/1.0">
>     <csv:record number="1">
>         <csv:field number="1">System</csv:field>
>         <csv:field number="2">Pump and Valve System</csv:field>
>     </csv:record>
> </csv:document></systems>
>
> The following xslt will not find a match:
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  xmlns:csv="http://apache.org/cocoon/csv/1.0#"
> version="2.0">
>  <xsl:output method="xml" indent="yes" />
>  <xsl:template match="/">
>    <!-- Write out the standard OWL start elements and imports-->
>    <xsl:apply-templates
> select="/relex/systems/csv:document/csv:record" />
>  </xsl:template>
>
>
>  <xsl:template
> match="/relex/systems/csv:document/csv:record">
>  <matchedIt/>
>  </xsl:template>
> </xsl:stylesheet>
>
> I can match the "relex" and the "systems" tags just fine, but neither of the
> ones with colons in them.  I've tried several variations on the template
> match (e.g. match=//csv:record, etc).  any ideas?
>
> Thanks,
> Jeff

Namespaces are incredibly useful when merging XML from different
systems; I strip them as soon as possible because processing them is
annoying. An extra transform copying everything with strip-namespaces
often makes XSL code much more maintainable. Otherwise...

local-name() is your friend.  Example:
   <xsl:apply-templates select="*[local-name() != 'index']"/>
Rewriting your example:
   <xsl:apply-templates select="/relex/systems/*[local-name() =
'document']/*[local-name() = 'record']" />
Messy, but it works.

Enjoy,
solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message