Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade xslt 1.0 to xslt 2.0?

I am new in xml and xslt.

I using classic asp for my web coding. I using windows platform for my web pages. and in the local computer id "localhost/mywebpage".

Today i try to run an xml file with xslt but i getting error

 msxml3.dll error '80004005'

Keyword xsl:template may not contain xsl:for-each-group. 

below is my running code

in xml

<Lakes>
  <Lake>
    <id>1</id>
    <Name>Caspian</Name>
    <Type>Natyral</Type>
  </Lake>
  <Lake>
    <id>2</id>
    <Name>Moreo</Name>
    <Type>Glacial</Type>
  </Lake>
  <Lake>
    <id>3</id>
    <Name>Sina</Name>
    <Type>Artificial</Type>
  </Lake>
</Lakes>

In xslt (XSLT 2.0)

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:for-each-group select="Lakes/Lake" group-by="Type">
            <xsl:result-document href="file{position()}.xml">
                <Lakes>
                    <xsl:copy-of select="current-group()"/>
                </Lakes>
            </xsl:result-document>
        </xsl:for-each-group>
    </xsl:template>
</xsl:stylesheet>

im my asp page

<%
        'load xml
        set xml = server.createobject("microsoft.xmldom")
        xml.async = false
        xml.load(server.mappath("test.xml"))

        'load xsl
        set xsl = server.createobject("microsoft.xmldom")
        xsl.async = false
        xsl.load(server.mappath("test.xsl"))

        set xdm= server.createobject("msxml2.domdocument")
        xdm.async = false
        xdm.loadxml(xml.transformnode(xsl))
        xdm.save(server.mappath("test_r.xml"))

%>

Wht i need to upgrade my xslt1.0 to xslt2.0?

like image 674
user475464 Avatar asked Jan 25 '26 21:01

user475464


1 Answers

You need to use an XSLT 2.0 processor; Microsoft does not have one so if you want to use XSLT 2.0 you need to look into third party options, like AltovaXML http://www.altova.com/altovaxml.html. Its API is documented at http://manual.altova.com/AltovaXML/altovaxmlcommunity/index.html?axcom_xslt2.htm. That is your best option for classic ASP as far as I can tell, if you move to ASP.NET then the .NET version of Saxon 9 or XmlPrime are also XSLT 2.0 processors available.

like image 91
Martin Honnen Avatar answered Jan 28 '26 06:01

Martin Honnen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!