On 7/11/08, Jeff Schmitz <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
