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

Re: Why is 'analyze-string' producing this weird outpu

Subject: Re: Why is 'analyze-string' producing this weird output?
From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Aug 2023 13:44:56 -0000
Re:  Why is 'analyze-string' producing this weird outpu
Your group counting is off (using entities is not helping:-)

<!ENTITY section-num "[0-9]+(\.[0-9]+)+">
                                                ^^^1
<!ENTITY section-name "[A-Z][a-zA-Z /]+">
<!ENTITY paren "\([^\)]+\)">
I use 'analyze-string' to break apart the input:

<xsl:analyze-string select="$line" regex="^(&section-num;) (&section-name;)
(&paren;)$">


^^^1                   ^^^3                    ^^^4


David




On Wed, 23 Aug 2023 at 14:40, Roger L Costello costello@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Folks,
>
> I'm baffled.
>
> Here is a sample input line:
>
> 5.2 Record Type (S/T)
>
> The first part -- 5.2 -- is the 'section number'.
>
> The second part -- Record Type -- is the 'section name'.
>
> The third part -- (S/T) -- is the 'abbreviated name'.
>
> I want the XSLT to generate this:
>
> <header>
>     <section-num>5.2</section-num>
>     <section-name>Record Type</section-name>
>     <abbreviated-name>(S/T)</abbreviated-name>
> </header>
>
> I created several ENTITIES for use by my XSLT:
>
> <!ENTITY section-num "[0-9]+(\.[0-9]+)+">
> <!ENTITY section-name "[A-Z][a-zA-Z /]+">
> <!ENTITY paren "\([^\)]+\)">
>
> I use 'analyze-string' to break apart the input:
>
> <xsl:analyze-string select="$line" regex="^(&section-num;)
> (&section-name;) (&paren;)$">
>     <xsl:matching-substring>
>         <header>
>             <section-num><xsl:value-of
> select="regex-group(1)"/></section-num>
>             <section-name><xsl:value-of
> select="regex-group(2)"/></section-name>
>             <abbreviated-name><xsl:value-of
> select="regex-group(3)"/></abbreviated-name>
>         </header>
>     </xsl:matching-substring>
> </xsl:analyze-string>
>
> That produces this erroneous output:
>
> <header>
>     <section-num>5.2</section-num>
>     <section-name>.2</section-name>
>     <abbreviated-name>Record Type</abbreviated-name>
> </header>
>
> I am baffled why I am getting that output.
>
> What am I doing wrong, please?
>
> /Roger

Current Thread

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
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.