[xsl] Query regarding usage of <xsl:sort> in MSXML

Subject: [xsl] Query regarding usage of <xsl:sort> in MSXML
From: Nirmala R <nirmala.r@xxxxxxxxxx>
Date: Wed, 16 Oct 2002 09:21:35 +0530
Hello all,

I am using MSXML4.0. Have a query regarding usage of <xsl:sort> in MSXML

Lets say the hirearchy of my xml dom document is like this:

  <Patient name=pat1name id=pat1id>
	<Study uid=st1.1.uid comments="study1">

	<Study uid=st1.2.uid comments="study2">

<Patient name=pat2name id=pat2id>
	<Study uid=st2.1.uid comments="study1">

	<Study uid=st2.2.uid comments="study2">

And I have a Stylesheet for this XML like this:

<xsl:stylesheet version="1.0"
<xsl:template match="Media">

<xsl:apply-templates select="Patient">
<xsl:sort select="name" data-type="text" order="descending"/>


<xsl:template match="Patient">
<xsl:value-of select="@name"/><br/>


I want to get the name attribute of all Patients with the order of name
in "descending" order.

I need to do the name using MSXML VC++ MFC. (msxml4.dll is added to the
MFC using ole automation)

	............................. // Dom Document loaded and
dispatch available
	LPDISPpaCH lpDisp = myDOMDoc.getElementsByTagName("Media");
	IXMLDOMNode aMediaNode(lpDisp);

	// Get all the Patient Nodes under Media
	lpDisp = aMediaNode.selectNodes("Patient");
	IXMLDOMNodeList aPatNodesList(lpDisp);

	// Walk through the PatNodesList and get the Attributes
	// reset the iterator of the list
	for (int i=0; i < aPatNodesList.GetLength(); ++i)	
	      lpDisp = aPatNodesList.GetItem(i);
                  IXMLDOMNode aPatNode(lpDisp);

	      // Get the attributes
	     lpDisp = aPatNode.GetAttributes();

	    // Attributes come in a NodeMap, from that get the name
	    IXMLDOMNamedNodeMap aPatAttributes(lpDisp);

	   // name is the 0th attribute (first item)
              lpDisp = aPatAttributes.GetItem(0);
	  IXMLDOMNode aAtt(lpDisp);
	COleVariant aVal(aAtt.GetNodeValue());
	CString aAttValue(aVal.bstrVal);
         } // for all the Patient Nodes under Media

	Here, I want to get all the Patient nodes in the order of name
in descending.
	i.e. like pat2name, pat1name instead of pat1name, pat2name.

	I understand that there is an API for doing a transformNode
where we can mention the stylesheet/string to do the same.
	But I am not able to findout where it has to be done, how to
combine the selectNodes with this functionality.
	Can you tell me how to fitin that sorting functionlaity in the
above code?

	Can any one of you help me in this regard?

Thanks in advance,

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread