xsl-list
[Top] [All Lists]

AW: struggling with <xsl:analyze-string>

2005-01-26 08:47:41
Hi David,

Thank you very much for your quick answer.

part/section/par[(_at_)class='45_UeberschrPara' and
  contains(., 'In-Kraft-Treten')]/following-sibling::*

Unfortunately, the structure given may vary very much, meaning that there may be
additional levels or <inline> elements to search within.
But I should be able to use 
following::* then.
Don't know if that performs better. Does it?

I suppose that the curly bracetts are giving my troubles...
The regex attribute is an attribute value template so {} will 
be exeuted as an Xpath and the resulting string used in place 
of the AVT so the regex there is \d4 you need {{ }} to make a 
{} group as in any AVT.

Ah, that makes it a lot clearer. Thanks.

It may be just because you have simplifed too much but it 
would look as if you don't need to use analyze-string here at 
all but just add [matches(.,'\d{4}')] to the select 
expression in your for-each.

That could indeed be the case. I just started to learn the new functions and 
instructions dealing with regular expressions, so I am a total newbie here.
If I use the matches function in my select expression, how can I pass my found 
date
to the named template?

Here is what I tried (input is the same as before):

<xsl:template match="/document">
        <bekanntmachung ordnungszeichen="Paragraf">
                <xsl:attribute name="gilt-ab">
                        <xsl:choose>
                                <xsl:when 
test="part/section/par[(_at_)class='45_UeberschrPara' and contains(., 
'In-Kraft-Treten')]">
                                        <xsl:for-each 
select="part/section/par[(_at_)class='45_UeberschrPara' and contains(text(), 
'In-Kraft-Treten')]/following::*">
                                                <!-- This regular expression is 
not working -->
                                                <xsl:analyze-string select="." 
regex="\d{{1,2}}.\s\w+.\s\d{{4}}" >
                                                        <xsl:matching-substring>
                                                                <xsl:value-of 
select="."/>
                                                                
<xsl:call-template name="get.date">
                                                                        
<xsl:with-param name="text" select="." as="xs:string"/>
                                                                
</xsl:call-template>
                                                        
</xsl:matching-substring>
                                                </xsl:analyze-string>
                                        </xsl:for-each>
                                </xsl:when>
                                <xsl:otherwise>
                                        <xsl:text>01.01.1000</xsl:text>
                                </xsl:otherwise>
                        </xsl:choose>
                </xsl:attribute>
        </bekanntmachung>
</xsl:template>

In my output the attribute "gilt-ab" is empty. Since I have never written any 
regular expresson before, 
there is surely something wron with it. I strongly suspect the "." in it.
The regular expression should match strings like "1. Jänner 2004", "12. 
Dezember 2003" etc.

Thank you very much for your patience!

wbr,
Roman

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>