[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] sort with different files


Subject: RE: [xsl] sort with different files
From: "Markus Hanel" <markus.hanel@xxxxxx>
Date: Fri, 23 Apr 2004 14:23:51 +0200 (MEST)

many thanks!
markus
> You are only retrieving the last name from one file. Your XPath: 
> document(./url/@path)/lastname\
> seems to be coming from the context of pers_data, in which case there will
> only be one url loaded.
> 
> You could try something like this:
> 
> <xsl:template match="/root">
>   <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="node">
>   <!-- Load all the pers_data urls into a variable for access --> 
>   <xsl:variable name="data" select="document(pers_data/url/@path)"/>
>   
>   <xsl:for-each select="pers_data[@status='active']">
>   <xsl:sort select="$data/pers_data[@id = current()/@id]/lastname"/>
>     <lastname>
>     <xsl:value-of select="$data/pers_data[@id = current()/@id]/lastname"/>
>     </lastname>
>   </xsl:for-each>
> </xsl:template>
> 
> Josh
> 
> -----Original Message-----
> From: Markus Hanel [mailto:markus.hanel@xxxxxx]
> Sent: Thursday, April 22, 2004 4:27 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] sort with different files
> 
> 
> I have tried it with the document, but the problem is that i work with the
> file students.xml where the pers_data nodes included. But the pers_datas
> are
> destaged with a url. Which document must I select by the xsl element sort?
> 
> > you can do a sort using the document function if thats what you mean
> > 
> > -----Original Message-----
> > From: Markus Hanel [mailto:markus.hanel@xxxxxx]
> > Sent: 22 April 2004 12:16
> > To: xsl mailinglist
> > Subject: [xsl] sort with different files
> > 
> > 
> > 
> > Hello,
> > i have a table, where I want to list some students given by there
> > pers_data
> > in the file students.xml. Therefore I made a file a_format.xml to
> generate
> > columns automaticaly which are given as child of the node interviewer.
> In
> > the file students.xml the pers_data is destaged with a url.
> > My problem is now to sort the students by their lastname. The difficult
> is
> > that there are different files!
> > I hope someone can help me.
> > Many thanks
> > markus
> > 
> > file a_format.xml
> > <format>
> > ...
> >   <interviewer>
> >     <show>id</show>
> >     <show>lastname</show>
> >     <show>surname</show>
> >     <show>userid</show>
> >     <show>sex</show>
> >     <show>birth</show>
> >     <show>class</show>
> >   </interviewer>
> > ...
> > </format>
> > 
> > file students.xml
> > <root>
> > ...
> > <node type="interviewee" status="active">
> >   <pers_data status="active" task="interviewee" id="3">
> >     <url path="/qpers_data/3.xml" proto="file">
> >     </url>
> >   </pers_data>
> >   <pers_data status="active" task="interviewee" id="4">
> >     <url path="/qpers_data/4.xml" proto="file">
> >     </url>
> >   </pers_data>
> > </node>
> > ...
> > </root>
> > 
> > file 3.xml
> > 
> > <pers_data task="interviewee" id="3" status="active">
> >   <proto>file</proto>
> >   <type>interviewee</type>
> >   <surname>name</surname>
> >   <lastname>name</lastname>
> > ...
> > </pers_data>
> > 
> > xsl stylesheet:
> > 
> > <table>
> >   <tr>
> > <!--generate columns automaticaly which are given in a_format.xml -->
> >     <xsl:for-each
> > select="document('/qxml/a_format.xml')/format/interviewer/child::*">
> >       <xsl:variable name="show_node" select="." />
> >       <th><xsl:value-of
> >
>
select="../../style_body/style_display/translation/*[name()=concat('trans_',
> > $show_node)]"
> > /></th>
> >     </xsl:for-each>
> >   </tr>
> > <!-- list the pers_data of the file students.xml -->
> >   <xsl:for-each
> select="$self_node/pers_data[attribute::status='active']">
> > <!-- sort ???????? -->
> >   <xsl:sort select="document(./url/@path)/lastname" />
> >   <xsl:variable name="pers_data_file" select="document(./url/@path)" />
> >   <xsl:variable name="pos" select="position()" />
> >       <tr>
> >         <xsl:for-each
> > select="document('/qxml/a_format.xml')/format/interviewer/child::*">
> >         <xsl:variable name="show" select="." />
> >           <td>
> >             <xsl:value-of
> > select="$self_node/pers_data[$pos]/*[name()=$show]
> > | $pers_data_file/pers_data/*[name()=$show]" />
> >           </td>
> >         </xsl:for-each>
> >       </tr>
> >   </xsl:for-each>
> > </table>


Current Thread
Keywords
xsl