[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

=?utf-8?B?UkU6IFt4bWwtZGV2XSBtYXRjaGluZyB0ZXh0IHdpdGggcmVnZXhw?==?utf-8?

  • To: =?utf-8?B?J0RhcmUgT2Jhc2Fuam8n?= <dareo@m...>, xml-dev@l...
  • Subject: =?utf-8?B?UkU6IFt4bWwtZGV2XSBtYXRjaGluZyB0ZXh0IHdpdGggcmVnZXhw?==?utf-8?B?IGluIHhwYXRo?=
  • From: =?utf-8?B?V2FubmhlZGVuLCBLbnV0?= <knut.wannheden@p...>
  • Date: Thu, 8 Aug 2002 17:11:01 +0200

subject utf 8
Title: RE: matching text with regexp in xpath

I wasn't going to make use of any XSLT engine at all.  The intention is to use it as part of an XPath expression inside a XML processing Java application.  Currently I don't even have to be able to use the function from inside a document, just in the processor.  I'm using dom4j and Jaxen to process the XML document and run XPath queries.

I now have a first implementation of my function, although I still have a problem with the namespaces.  I wasn't able to register the function with an associated namespace, just without namespace.  But there must be some solution to that.  Maybe someone can tell me how I can get that to work...  This is what I'm doing now (without namespace):

        XPathFunctionContext ctx = new XPathFunctionContext();
        // myFunction implements org.jaxen.Function
        ctx.registerFunction(null, "match", myFunction);
        XPath xp = DocumentFactory.getInstance().
                createXPath("/a/b[match(@c, '{.}')]");
        xp.setFunctionContext(ctx);
        List matches = xp.selectNodes(element);

If I use a namespace I get an InvalidXPathException when calling createXPath() even though I have it registered using DocumentFactory.setXPathNamespaceURIs().

--
knut

> -----Original Message-----
> From: Dare Obasanjo [mailto:dareo@m...]
> Sent: Donnerstag, 8. August 2002 16:58
> To: Wannheden, Knut; xml-dev@l...
> Subject: RE: matching text with regexp in xpath
>
>
> It depends on what XSLT processor you are using to determine
> what extension functions are available to you or embedded
> scripting options you have.
>
>       -----Original Message-----
>       From: Wannheden, Knut [mailto:knut.wannheden@p...]
>       Sent: Thu 8/8/2002 2:32 AM
>       To: xml-dev@l...
>       Cc:
>       Subject: matching text with regexp in xpath
>      
>      
>
>       Hi,
>
>       I was wondering if anybody knows of an extension
> function to XPath which allows me to match text and attribute
> values in XML documents against regular expressions.  I'd
> like to be able to write something like:
>
>               /a/b[re:match(@c, '{.}')]
>
>       to match all elements where an attribute has a value
> matching the regexp {.} (AVT) or:
>
>               /a/b/@c[re:match(., '{.}')]
>
>       to match the attribute elements themselves.
>
>       If there isn't such a thing yet I imagine it shouldn't
> be to hard to write.  Can somebody give me some
> hints/directions on how to get started with this?
>
>       Thanks,
>
>       --
>       knut
>
>


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.