My bet is that you are not using an XSLT2 processor,
there is nothing wrong with your code
analyze-string does not like empty strings as an input, som make sure that $Textstr can not be empty
Main Topics
Browse All TopicsWhen I try and transform my data with my stylesheet I get the error:
"Keyword xsl:template may not contain xsl:analyze-string"
My template looks like this:
<xsl:template name="CheckValid">
<xsl:param name="Textstr"/>
<xsl:param name="Expression"/>
<xsl:param name="Replacestr"/>
<xsl:param name="Type"/>
<xsl:analyze-string select="$Textstr" regex="$Expression">
<xsl:matching-substring>
<xsl:choose>
<xsl:when test="$Type = 'date'">
<xsl:call-template name="InternationalizeDate
<xsl:with-param name="Datestr" select="$Textstr"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Textstr"/>
</xsl:otherwise>
</xsl:choose>
</xsl:matching-substring>
<xsl:non-matching-substrin
<xsl:value-of select="$Replacestr"/>
</xsl:non-matching-substri
</xsl:analyze-string>
</xsl:template>
The InternationalizeDate template is as follows:
<xsl:template name="InternationalizeDate
<xsl:param name="Datestr"/>
<xsl:value-of select="concat(substring($
substring($Datestr, 1, 2))"/>
</xsl:template>
and finally I call my CheckValid template as follows:
<DateofBirth>
<xsl:if test="normalize-space(Cell
<xsl:call-template name="CheckValid">
<xsl:with-param name="Textstr" select="Cell[12]/Data"/>
<xsl:with-param name="Expression" select="$dateregexp"/>
<xsl:with-param name="Replacestr" select="''"/>
<xsl:with-param name="Type" select="date"/>
</xsl:call-template>
</xsl:if>
</DateofBirth>
Finally the dateregexp param is defined as follows:
<xsl:param name="dateregexp" select="'([0]?[1-9]|[12][0
Can anyone see what I am doing wrong? I have defined my stylesheet as using version 2.0.
Any help much appreciated.
Thanks
Sam
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I should add that I calling the Transform method from a VB6 executable (not VB.NET) so not sure I can use Saxon9 as for Java or .NET and my VB calls are like this:
Dim objXSL As MSXML2.DOMDocument
Dim objXML As MSXML2.DOMDocument
Dim strXSLFilePath As String
strXSLFilePath = Get_StyleSheet(strFormat)
Set objXSL = CreateObject("MSXML2.DOMDo
'Turn off asyncronous file loading.
objXSL.async = False
objXSL.Load (strXSLFilePath)
Transform_FileData = objXML.transformNode(objXS
OK, you are using msxml. That is a XSLT1 processor, you can not use XSLT2 functionality with msxml
You can use Saxon in .net,
you can not use saxon in classic vb.
So you either port your application to .net or you port your stylesheet to XSLT1
Note that inside msxsl you can use JavaScript.
Given that the regex you have could be a daunting task in XSLT1,
I might recommend that you develop that part in JavaScript inside the XSLT
Here is a simple straightforward example of using JavaScript in an msxml xslt processor
you need to declare
xmlns:msxsl="urn:schemas-m
and a namespace for your javascript function
xmlns:myjs="urn:internal:m
(could be a different prefix and namespace, as long as you have one it is OK)
Then have a script tag in the msxsl namespace and implement the namespace by setting the prefix
<msxsl:script language="JavaScript" implements-prefix="myjs">
in this block, define your javascript functions (here you make a function that processes the text by a regex)
works well, the reason I don't do this very often is that it binds your xslt to one specific processor
Business Accounts
Answer for Membership
by: GertonePosted on 2009-07-03 at 01:48:59ID: 24770938
I will have a look in a minute,
but are you sure that you are using a XSLT2 processor?
you should use Saxon9 (or some other XSLT2 processor- for that