StuckOnceAgain
asked on
Error message - xsl:apply-templates may not contain xsl:sort
I get the above error message in my code and I am looking to see if someone can help me out.
Here is what I am trying to do:
I have an XSL file - sort.xsl and it has the following data:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="RecordSet">
<xsl:apply-templates select="Record">
<xsl:sort select="DESC" />
<xsl:sort select="NUMBER" />
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
I have an xml file that I need sorted. Test.xml
<RecordSet>
<Record rownum="1">
<DESC>Good Product</DESC>
<NUMBER>123</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="2">
<DESC>Very Bad Product</DESC>
<NUMBER>123A</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="2">
<DESC>Very Good Product</DESC>
<NUMBER>ABC</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="1">
<DESC>Bad Product</DESC>
<NUMBER>123SDA</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="2">
<DESC>Very Bad Product</DESC>
<NUMBER>123</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="2">
<DESC>Very Bad Product</DESC>
<NUMBER>123</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<RecordSet>
I need to do this in an ASP page. This is part of a huge ASP page, so I am pasting only the pertinent information here.
Set objXML = Server.CreateObject ("MSXML2.DOMDocument.3.0")
Set objSortXSL = Server.CreateObject ("MSXML2.DOMDocument.3.0")
If Not objSortXSL.load(server.Map Path("Sort .xsl")) then
Response.Write "Problems"
Response.end
End If
Response.write objPC2XML.transformNode(ob jSortXSL)
Upon execution I get the following error message while trying to transform the node.
Error Type:
msxml3.dll (0x80004005)
Keyword xsl:apply-templates may not contain xsl:sort.
I have MSXML3 version SP3 installed in side by side mode with V2.
If someone can help that would be great. Thanks.
Hari.
Here is what I am trying to do:
I have an XSL file - sort.xsl and it has the following data:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="RecordSet">
<xsl:apply-templates select="Record">
<xsl:sort select="DESC" />
<xsl:sort select="NUMBER" />
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
I have an xml file that I need sorted. Test.xml
<RecordSet>
<Record rownum="1">
<DESC>Good Product</DESC>
<NUMBER>123</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="2">
<DESC>Very Bad Product</DESC>
<NUMBER>123A</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="2">
<DESC>Very Good Product</DESC>
<NUMBER>ABC</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="1">
<DESC>Bad Product</DESC>
<NUMBER>123SDA</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="2">
<DESC>Very Bad Product</DESC>
<NUMBER>123</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<Record rownum="2">
<DESC>Very Bad Product</DESC>
<NUMBER>123</NUMBER>
<QUANTITY>5</QUANTITY>
</Record>
<RecordSet>
I need to do this in an ASP page. This is part of a huge ASP page, so I am pasting only the pertinent information here.
Set objXML = Server.CreateObject ("MSXML2.DOMDocument.3.0")
Set objSortXSL = Server.CreateObject ("MSXML2.DOMDocument.3.0")
If Not objSortXSL.load(server.Map
Response.Write "Problems"
Response.end
End If
Response.write objPC2XML.transformNode(ob
Upon execution I get the following error message while trying to transform the node.
Error Type:
msxml3.dll (0x80004005)
Keyword xsl:apply-templates may not contain xsl:sort.
I have MSXML3 version SP3 installed in side by side mode with V2.
If someone can help that would be great. Thanks.
Hari.
ASKER
I am not using V2. I Explicitly call out V3 with
CreateObject ("MSXML2.DOMDocument.3.0")
Also, I am trying the transformation on the server side and not on the clinet side.
CreateObject ("MSXML2.DOMDocument.3.0")
Also, I am trying the transformation on the server side and not on the clinet side.
OK. Well, I think you need to take out the select attribute for the apply-templates statement. That might help as I don't think I've seen that in any of the XML I've seen:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="RecordSet">
<xsl:apply-templates>
<xsl:sort select="DESC" />
<xsl:sort select="NUMBER" />
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
Brad
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="RecordSet">
<xsl:apply-templates>
<xsl:sort select="DESC" />
<xsl:sort select="NUMBER" />
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
Brad
I've seen the select attribute used this way:
<xsl:template match="Record">
Description: <xsl:apply-templates select="DESC"/>
Number: <xsl:apply-templates select="NUMBER"/>
Quantity: <xsl:apply-templates select="QUANTITY"/>
<xsl:text></xsl:text>
</xsl:template>
Does that help?
Brad
<xsl:template match="Record">
Description: <xsl:apply-templates select="DESC"/>
Number: <xsl:apply-templates select="NUMBER"/>
Quantity: <xsl:apply-templates select="QUANTITY"/>
<xsl:text></xsl:text>
</xsl:template>
Does that help?
Brad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
acperkins, U THE MAN!!!!!!!!!!!!!!!
duh, i can't believe that i used the old namespace. Yup that did the trick.
Yea the xml not being well formed was a typo. But the namespace wasnt.
Thanks a bunch.
duh, i can't believe that i used the old namespace. Yup that did the trick.
Yea the xml not being well formed was a typo. But the namespace wasnt.
Thanks a bunch.
http://www.netcrucible.com/xslt/msxml-faq.htm.
Brad