xsl-list
[Top] [All Lists]

RE: How to call extension function from xpath multiple times?

2005-01-04 04:03:27
Hi,

  Got it. It should be z instead of a 
        <xsl:template match="z"> instead of  <xsl:template match="a">

regards
Manpreet Singh
        
-----Original Message-----
From: Manpreet Singh 
Sent: Tuesday, January 04, 2005 4:01 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: FW: [xsl] How to call extension function from xpath multiple
times?
Importance: High


Hi,

My Source xml:

<?xml version="1.0" encoding="UTF-8"?>
<z>
        <b13>123<a>ftp<c12>c12</c12></a></b13>
        <b2>456<a>ftp1<c1>c1</c1></a></b2>
</z>

  I am working with the following xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:dit="Tester">
        <xsl:template match="a">
                <xsl:apply-templates 
select="*[dit:matchString('b_qstnmark_',local-name(.))]/a/*[dit:matchString('c_qstnmark_',local-name(.))]"/>
        </xsl:template>
        <xsl:template 
match="*[dit:matchString('b_qstnmark_',local-name(.))]/a/*[dit:matchString('c_qstnmark_',local-name(.))]">
                <xsl:value-of select="concat(local-name(.), ' - ', .)"/>
        </xsl:template>
</xsl:stylesheet>

The java class for the extension function i call is as follows:

import java.util.StringTokenizer;

public class Tester {
        public static boolean matchString(String pattern, String elemName) {
                int index = pattern.lastIndexOf("/");

                if(index != -1) {
                pattern = pattern.substring(index + 1);
                }

                pattern = pattern.replaceAll("_asterix_", "\\\\w*");
                pattern = pattern.replaceAll("_qstnmark_", "\\\\w");

                return java.util.regex.Pattern.matches(pattern, elemName);
        }
}

My problem is that the xpath of apply-templates above does not work. My 
template below never gets a call.

Any Help?

Regards
Manpreet Singh

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


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


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