Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2013, 05:50 AM
Authorized User
 
Join Date: Aug 2013
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default xsl:for-each?

Dear all,

I have now this problem:

I used xsl:analyze-string to match this regex

((.*)//)* (.*)

and I would like to pass onto xsl:matching-substring each of the eventual (.*)//.

if that possible?
I have tried with xsl:if and xsl:for-each select="regex-group(1)"

but I must be doing something wrong... or taking the problem from the wrong point

Thank you very much
 
Old August 15th, 2013, 07:08 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Yes, you are doing something wrong.

If you show us what you are doing then perhaps we can tell you what you are doing wrong.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old August 15th, 2013, 09:24 AM
Authorized User
 
Join Date: Aug 2013
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default

sorry, here is the full code.


Code:
<xsl:analyze-string select="." regex="((.*)//)* (.*)" flags="s">
                <xsl:matching-substring>
                    <xsl:if test="regex-group(1)">
<xsl:for-each select="regex-group(2)"><div>
                        <ab><lb/>
                            <xsl:variable name="brackets">
                                <xsl:call-template name="breakbrackets">
                                    <xsl:with-param name="textToBeProcessed"        select="regex-group(2)"/>
                                </xsl:call-template>
                            </xsl:variable>
                            <xsl:for-each select="$brackets">
                                <xsl:call-template name="upconversion"/>
                            </xsl:for-each>
                        </ab>
                    </div>
</xsl:for-each>
</xsl:if>
                    <div>
                        <ab><lb/>
                            <xsl:variable name="brackets">
                                <xsl:call-template name="breakbrackets">
                                    <xsl:with-param name="textToBeProcessed" select="regex-group(3)"/>
                                </xsl:call-template>
                            </xsl:variable>
                            <xsl:for-each select="$brackets">
                                <xsl:call-template name="upconversion"/>
                            </xsl:for-each>
                        </ab>
                    </div>
                </xsl:matching-substring>
                <xsl:non-matching-substring>
                    <ab>
                        <lb/><xsl:variable name="brackets">
                            <xsl:call-template name="breakbrackets">
                                <xsl:with-param name="textToBeProcessed" select="."/>
                            </xsl:call-template>
                        </xsl:variable>
                        <xsl:for-each select="$brackets">
                            <xsl:call-template name="upconversion"/>
                        </xsl:for-each>
                    </ab>
                </xsl:non-matching-substring>
            </xsl:analyze-string>
        </div>
    </xsl:template>
Thank you very much
 
Old August 15th, 2013, 09:55 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

regex-group() always returns a single string, so using it in xsl:for-each doesn't make much sense: though it's legal and won't do any harm, it suggests you're confused about the logic.

you say you want to process "each of the eventual (.*)//.", but that's surely regex-group(1) not regex-group(2).

Beyond that, I can't see immediately what's wrong - I can't see your input or your desired output or the various templates you are calling, so that's not surprising.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old August 15th, 2013, 10:11 AM
Authorized User
 
Join Date: Aug 2013
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default

I am, indeed.

is there any other function which you could suggest me to get each string?
I have asked for the regex-group(2) because I actually want the // not to be in the result.
I have texts like this

oioia daoinda // doaindsoai // dao ids nda etc.

where // is the separator and each is a test I want to process. There are cases in which there is only one, cases in which there are 20. with my code I match 1 or 2.

iIf there is one text I want it to do what is in the non matching, if it has more I want it to behave according to the matching (with the div and the ab in the div.

could I use tokenize() or matches()?

I am not immediately able to try unfortunately...

Thank you very much
 
Old August 15th, 2013, 11:10 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Can't you simply use

Code:
<xsl:for-each select="tokenize(.., '//')"
You seem to be making this far more complicated than it is.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to include mathml in xsl fo using xsl transformation dinesh.m@laserwords.co.in XSLT 0 July 9th, 2011 07:20 AM
xsl:function pass param to attribute of xsl:instruction bonekrusher XSLT 4 March 31st, 2009 09:06 AM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
differnce between xsl:apply-templates and xsl:call chandu.mca007 XSLT 2 June 12th, 2007 04:12 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.