You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Bernhard Wagner <bw...@xmlizer.biz> on 2002/12/19 15:11:34 UTC

[jelly] making xml:expr case-insensitive

In the examples coming with the distribution of jelly there is
\jakarta-commons-sandbox\jelly\src\test\org\apache\commons\jelly\html\exampl
e.jelly

This script extracts the title of index.html using the xpath expression
"$doc/html/head/title".

If you change the case setting of any of the tags in index.html without
adapting the xpath expression the title element is no longer found.

My questions:

  1) Can I configure html:parse to change the case setting of the retrieved
document? How?
  2) Is there any transformer available that can change the case setting of
element and attribute names?
  3) Can I configure x:expr to ignore the case settings of the xpath
expression given in the select attribute? How?

==Bernhard


RE: [jelly] making xml:expr case-insensitive

Posted by Bernhard Wagner <bw...@xmlizer.biz>.
Hi James

I tested it and it worked immediately. Thank you very much for reacting so
quickly!

==Bernhard

> -----Original Message-----
> From: James Strachan [mailto:james_strachan@yahoo.co.uk]
> Sent: Donnerstag, 19. Dezember 2002 16:04
> To: Jakarta Commons Users List
> Subject: Re: [jelly] making xml:expr case-insensitive
>
>
> From: "James Strachan" <ja...@yahoo.co.uk>
> > From: "Bernhard Wagner" <bw...@xmlizer.biz>
> > >
> > >   1) Can I configure html:parse to change the case setting of the
> > retrieved
> > > document? How?
> >
> >
> > The NeckoHTML parser already allows for this. I'll add these
> customisation
> > options to the Jelly tag in a moment.
>
> OK I've finished the unit tests - it seems to work fine now. Its
> all in CVS
> HEAD.
>
>
> You can now use NeckoHTML's features for turning elements or attributes
> upper case or lower case (or in the case of elements, matching them) via
> specifying an element and attribute attributes.
>
> e.g. to upper case the elements but lowercase the attributes you can do...
>
>     <html:parse var="doc" html="index.html" element="upper"
> attribute="lower"/>
>
> or to make everything lower case
>
>     <html:parse var="doc" html="index.html" element="lower"
> attribute="lower"/>
>
>
> The default is to leave case as it was but to match element case (so that
> open and close elements have the same case).
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


Re: [jelly] making xml:expr case-insensitive

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "James Strachan" <ja...@yahoo.co.uk>
> From: "Bernhard Wagner" <bw...@xmlizer.biz>
> >
> >   1) Can I configure html:parse to change the case setting of the
> retrieved
> > document? How?
>
>
> The NeckoHTML parser already allows for this. I'll add these customisation
> options to the Jelly tag in a moment.

OK I've finished the unit tests - it seems to work fine now. Its all in CVS
HEAD.


You can now use NeckoHTML's features for turning elements or attributes
upper case or lower case (or in the case of elements, matching them) via
specifying an element and attribute attributes.

e.g. to upper case the elements but lowercase the attributes you can do...

    <html:parse var="doc" html="index.html" element="upper"
attribute="lower"/>

or to make everything lower case

    <html:parse var="doc" html="index.html" element="lower"
attribute="lower"/>


The default is to leave case as it was but to match element case (so that
open and close elements have the same case).

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Re: [jelly] making xml:expr case-insensitive

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Bernhard Wagner" <bw...@xmlizer.biz>
> In the examples coming with the distribution of jelly there is
>
\jakarta-commons-sandbox\jelly\src\test\org\apache\commons\jelly\html\exampl
> e.jelly
>
> This script extracts the title of index.html using the xpath expression
> "$doc/html/head/title".
>
> If you change the case setting of any of the tags in index.html without
> adapting the xpath expression the title element is no longer found.
>
> My questions:
>
>   1) Can I configure html:parse to change the case setting of the
retrieved
> document? How?


The NeckoHTML parser already allows for this. I'll add these customisation
options to the Jelly tag in a moment.

>   2) Is there any transformer available that can change the case setting
of
> element and attribute names?

Yes. The HTML parser, NeckoHTML already does this.


>   3) Can I configure x:expr to ignore the case settings of the xpath
> expression given in the select attribute? How?

XPath can do this kinda thing but its inefficient and a bit ugly. e.g.
$doc/*[upper-case(name())='FOO']

Best to let the HTML parser do it. Gimme 10 minutes or so and I'll reply
when I've JellyUnit tested this feature...

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com