You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Brent L Johnson <br...@bjohnson.net> on 2001/11/05 15:31:00 UTC

Template Matching

This is probably something that's more of an XPath issue - but does anyone
know of a quick way to get template matching to be case insentitive?  A lot
of the content for our website (runnng under cocoon 1.8.2 w/ tomcat) is
created by other non-technical people, some of which use upper case tags,
some lower, some mixed.  Is there a way to match case insensitive?

Thanks,

- Brent


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Template Matching

Posted by Jörg Heinicke <jh...@virbus.de>.
What about a "preparsing"?

<xsl:template match="*">
     <xsl:element name="{translate(name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
'abcdefghijklmnopqrstuvwxyz')}">
         <xsl:apply-templates select="*|@*|text()"/>
     </xsl:element>
</xsl:template>

<xsl:template match="@*">
     <xsl:attribute name="{translate(name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
'abcdefghijklmnopqrstuvwxyz')}"/>
</xsl:template>

<xsl:template match="text()">
     <xsl:copy/>
</xsl:template>

In a second stylesheet you have your normal processing with all letters in 
lower cases.

Joerg

Berin Loritsch wrote:

> Brent L Johnson wrote:
> 
>>This is probably something that's more of an XPath issue - but does anyone
>>know of a quick way to get template matching to be case insentitive?  A lot
>>of the content for our website (runnng under cocoon 1.8.2 w/ tomcat) is
>>created by other non-technical people, some of which use upper case tags,
>>some lower, some mixed.  Is there a way to match case insensitive?
>>
> 
> Not really.  XML itself is case-sensitive.  The mixed case you have to deal
> with are most likely invalid documents.  There is the posibility of changing
> everything to upercase:
> 
> <xsl:template match="translate(name(.), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')='FOO'">
> 
>   <!-- process foo -->
> 
> </xsl:template>
> 
> but, that is too messy.  You may want to make your tags all lowercase, and
> have them preprocessed first.  It is quite trivial to create a SAX Content
> Handler that performs a name.toLower() on all the element names and attribute
> names.
> 
> Either that or educate some folks--case does matter.
> 
> 
> 


-- 

System Development
VIRBUS AG
Fon +49(0)341-979-7435
Fax +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Template Matching

Posted by Berin Loritsch <bl...@apache.org>.
Brent L Johnson wrote:
> 
> This is probably something that's more of an XPath issue - but does anyone
> know of a quick way to get template matching to be case insentitive?  A lot
> of the content for our website (runnng under cocoon 1.8.2 w/ tomcat) is
> created by other non-technical people, some of which use upper case tags,
> some lower, some mixed.  Is there a way to match case insensitive?

Not really.  XML itself is case-sensitive.  The mixed case you have to deal
with are most likely invalid documents.  There is the posibility of changing
everything to upercase:

<xsl:template match="translate(name(.), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')='FOO'">

  <!-- process foo -->

</xsl:template>

but, that is too messy.  You may want to make your tags all lowercase, and
have them preprocessed first.  It is quite trivial to create a SAX Content
Handler that performs a name.toLower() on all the element names and attribute
names.

Either that or educate some folks--case does matter.


-- 

"Those who would trade liberty for
 temporary security deserve neither"
                - Benjamin Franklin

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


RE: Template Matching

Posted by Luca Morandini <l....@tin.it>.
> -----Original Message-----
> From: Henrik Hofmann [mailto:Henrik.Hofmann@creon-it.com]
> Sent: Monday, November 05, 2001 3:43 PM
> To: cocoon-users@xml.apache.org
> Subject: RE: Template Matching> 

> Yeah I think there is a way ;)
> 
> <xsl:template match="test">
> <xsl:template match="Test">
> <xsl:template match="TEst">
> <xsl:template match="TESt">
> <xsl:template match="TesT">
> .....
> ...
> 
> 
> But I hope for you you'll find one wich doesn't need that much of
> typing.

Maybe <xsl:template match="test|TEST|Test|TEst|TESt|TesT"> ?


--------------------------------------------- 
               Luca Morandini 
               GIS Consultant 
              lmorandini@ieee.org 
http://utenti.tripod.it/lmorandini/index.html 
---------------------------------------------


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


RE: Template Matching

Posted by Henrik Hofmann <He...@creon-it.com>.
> This is probably something that's more of an XPath issue - 
> but does anyone know of a quick way to get template matching 
> to be case insentitive?  A lot of the content for our website 
> (runnng under cocoon 1.8.2 w/ tomcat) is created by other 
> non-technical people, some of which use upper case tags, some 
> lower, some mixed.  Is there a way to match case insensitive?
Yeah I think there is a way ;)

<xsl:template match="test">
<xsl:template match="Test">
<xsl:template match="TEst">
<xsl:template match="TESt">
<xsl:template match="TesT">
.....
...


But I hope for you you'll find one wich doesn't need that much of
typing.

Bye





---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>