[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] java Regex call


Subject: RE: [xsl] java Regex call
From: David.Pawson@xxxxxxxxxxx
Date: Thu, 10 Jul 2003 12:43:32 +0100

> So the string is broken into two matching substrings ('ABC_PARA' and
> '_PARA') with a non-matching substring of '_' in between. And you get
> two lots of output because you're generating one for each of the
> matching substrings.

Ah! Getting very close to stateful here Jeni?

I hadn't figured the 'iteration' idea.
I'd have expected (without thinking too closely) all the matches
to have come up in the      <xsl:matching-substring>  section,
then all the non matching in the following <xsl:non-matching-substring>
section.

http://www.w3.org/TR/xslt20/#element-analyze-string
only hints at this 'ordering',

While the xsl:matching-substring instruction is active, ...
the regex-group parameter is sequential whilst active I guess.

I might reasonably expect that regexp-group(4) would get hold of the fourth
match string? This isn't true if there is a mismatch in between?
Yet is true if I get sequential matches?
A bit smelly IMO.

Thanks for the clarification though.

Using:

 <xsl:variable name="res" as="item()*">
   <xsl:analyze-string select="$input" regex="{$regex}">
      <xsl:matching-substring>
        <GROUP1><xsl:value-of select="regex-group(1)" /></GROUP1>
        <GROUP2><xsl:value-of select="regex-group(2)" /></GROUP2>
        <GROUP3><xsl:value-of select="regex-group(3)" /></GROUP3>
      </xsl:matching-substring>
      <xsl:non-matching-substring>
        <mismatch><xsl:value-of select="."/></mismatch>
      </xsl:non-matching-substring>
    </xsl:analyze-string>
  </xsl:variable>

  <xsl:copy-of select="$res"/>

 gives:

<GROUP1>ABC_PARA</GROUP1>
<GROUP2>ABC</GROUP2>
<GROUP3/>
<mismatch>_</mismatch>
<GROUP1>_PARA</GROUP1>
<GROUP2/>
<GROUP3/>

Which is close to usable, though very messy.
Need to work out that the second group, first item
is actually the fourth. Doable, but messy.


Thanks Jeni.

regards DaveP



 


- 

NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 
system.

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread