[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Error message - xsl:apply-templates may not contain xsl:sort

Posted on 2003-10-24
6
Medium Priority
?
468 Views
Last Modified: 2010-05-18
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.MapPath("Sort.xsl")) then
         Response.Write "Problems"
         Response.end
End If

Response.write objPC2XML.transformNode(objSortXSL)

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.



0
Comment
Question by:StuckOnceAgain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:Brad Dobyns, CSM
ID: 9617579
Well, you'll need to do away with Version 2 because XSLT isn't supported with MSXML2. If you're doing client-side transformation in Internet Explorer, you need MSXML3 installed in replace mode. Try reading the MSXML FAQ at
http://www.netcrucible.com/xslt/msxml-faq.htm.

Brad
0
 

Author Comment

by:StuckOnceAgain
ID: 9617667
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.
0
 
LVL 7

Expert Comment

by:Brad Dobyns, CSM
ID: 9617779
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Expert Comment

by:Brad Dobyns, CSM
ID: 9617797
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
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 400 total points
ID: 9617864
There are a number of problems here:
1. I suspect that this is a typo but your XML sample is not well-formed.
2. The old namespace: "http://www.w3.org/TR/WD-xsl" is not supported in v4 (and yes I realize you are still using v3).

If I use v3 with your XSL I can duplicate your problem, if on the other hand I use the newer namespace I do not get the error you report. As in:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <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 get the same result with both v3 and v4:
<?xml version="1.0" encoding="UTF-16"?>Bad Product123SDA5Good Product1235Very Bad Product1235Very Bad Product1235Very Bad Product123A5Very Good ProductABC5

Anthony
0
 

Author Comment

by:StuckOnceAgain
ID: 9617933
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question