Subject: RE: [xsl] Query regarding usage of <xsl:sort> in MSXML From: "Kevin Collins" <kcollins@xxxxxxx> Date: Wed, 16 Oct 2002 09:24:28 -0400 |
Nirmala, Use the transformNodeToObject method, as documented here: http://msdn.microsoft.com/library/en-us/xmlsdk/htm/xml_mth_sz_2jp0.asp It lets you apply a stylesheet to a DOM node and returns a new node. The above link shows an example in C++. Kevin > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Nirmala R > Sent: Wednesday, October 16, 2002 12:37 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] Query regarding usage of <xsl:sort> in MSXML > > > Sorry, It should have been @name. That was an error while typing. > > My problem is not in the XSL. I would like to introduce this > sorting in the > VC++ code. > (MSXML). > > Right now to get all the Patient nodes under Media, am doing > > LPDISPpaCH lpDisp = myDOMDoc.getElementsByTagName("Media"); > IXMLDOMNode aMediaNode(lpDisp); > > // Get all the Patient Nodes under Media > lpDisp = aMediaNode.selectNodes("Patient"); > IXMLDOMNodeList aPatNodesList(lpDisp); > > Here, while giving the XPath query for SelectNodes, I am > giving "Patient" which gives the list of patient nodes under > Media in the order how it is present in the XML document. I > would like to get all these nodes with the Patient name > attribute sorted in descending order. > > Thanks in advance, > Nirmala > > > -----Original Message----- > From: Kumaraswamy, Sachidanandam > [mailto:Sachidanandam.Kumaraswamy@xxxxxxxxxxxxxx] > Sent: Wednesday, October 16, 2002 9:43 AM > To: 'nirmala.r@xxxxxxxxxx' > Subject: RE: [xsl] Query regarding usage of <xsl:sort> in MSXML > > > I guess this below line should be > > <xsl:sort select="name" data-type="text" order="descending"/> > > Like this. > > <xsl:sort select="@name" data-type="text" order="descending"/> > > And why do you want to do selectsingle mode in VC++ again?You > mean are you trying to navigate through the records returned > by sorted and filtered xml?Well,reply me..let me sovle it. > > Thanks, > Sachi > > > > Sachidanandam.E.K > Member Techinical Staff > > HCLT KT-ODC > sachidanandam.kumaraswamy@xxxxxxxxxxxxxx > <mailto:sachidanandam.kumaraswamy@xxxxxxxxxxxxxx> > > > -----Original Message----- > From: Nirmala R [mailto:nirmala.r@xxxxxxxxxx] > Sent: Wednesday, October 16, 2002 9:22 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Query regarding usage of <xsl:sort> in MSXML > > > Hello all, > > I am using MSXML4.0. Have a query regarding usage of > <xsl:sort> in MSXML > VC++ MFC. > > Lets say the hirearchy of my xml dom document is like this: > > <Media> > <Patient name=pat1name id=pat1id> > <Study uid=st1.1.uid comments="study1"> > </Study> > > <Study uid=st1.2.uid comments="study2"> > </Study> > </Patient> > > <Patient name=pat2name id=pat2id> > <Study uid=st2.1.uid comments="study1"> > </Study> > > <Study uid=st2.2.uid comments="study2"> > </Study> > </Patient> > </Media> > > > And I have a Stylesheet for this XML like this: > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="Media"> > > <xsl:apply-templates select="Patient"> > <xsl:sort select="name" data-type="text" order="descending"/> > </xsl:apply-templates> > > </xsl:template> > > <xsl:template match="Patient"> > <xsl:value-of select="@name"/><br/> > </xsl:template> > > </xsl:stylesheet> > > 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 > aPatNodesList.reset(); > 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 attribute > 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); > AfxMessageBox(aAttValue); > } // for all the Patient Nodes under Media > > QUERY: > > 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, > Nirmala > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Query regarding usage of , Nirmala R | Thread | [xsl] Insert a node into an attribu, Mauro Gaddo |
Re: [xsl] Another problem with name, G. Ken Holman | Date | [xsl] Cannot Access Attribute with , Clifford, Karen |
Month |