Hello !
Please, I need an XSL file sample to sort TABLES in a parent Table.
Thanks for any help !
Printable View
Hello !
Please, I need an XSL file sample to sort TABLES in a parent Table.
Thanks for any help !
hi there,
if you plan to use xpath with xslt then look at xsl:sort
--> http://www.google.com/#hl=en&sugexp=...d06a33501ac671
you could use xpath and for example vb or csharp to do your sorting and then write html output.
it really depends on how you plan to do this task.
best regards,
tonci korsano
Yes - but how to use it for sorting TABLES ? I searched over the internet, I found xsl:sort, this is a trivial task for sorting RECORDS.
BUT I have to sort TABLES, not RECORDS !!
Any sample code is welcome !
Thank you anyway!
hi there,
look at this example:
in this example, i sort with variables.Code:<xsl:param name="sortDirection" select="'descending'"/>
<xsl:param name="sortType" select="'text'" />
<xsl:template match="*">
<xsl:apply-templates>
<xsl:sort select="@*[name()=$sortBy]" data-type="{$sortType}" order="{$sortDirection}" />
</xsl:apply-templates>
</xsl:template>
match="*" applies to the whole dataset.
select="@*[name()=$sortBy]" applies a sort criteria by an attribute specified in parameter $sortBy.
data-type="{$sortType}" specifies the data type of this sort operation, which is specified in a parameter.
order="{$sortDirection}" specifies the direction, which again is passed by a parameter.
this file is called PlayerPerfomanceSort.xslt,
i call this xslt file for a transformation in a very old asp.net web page (not used anymore in a really long time).
i am submitting in case it might help.
that's it.Code:Protected Sub sortXML(ByVal field As String, ByVal direction As String, ByVal dataType As String)
'sort last stored procedure output without calling the corresponding stored procedure
'tks oct.21.2008
Dim XMLDoc As New XmlDocument
Dim XSLTDoc As XslTransform
Dim endT As New DateTime(CInt(EndDate.SelectedDate.Year.ToString), CInt(EndDate.SelectedDate.Month.ToString), CInt(EndDate.SelectedDate.Day.ToString), 23, 59, 59)
Dim startT As New DateTime(CInt(StartDate.SelectedDate.Year.ToString), CInt(StartDate.SelectedDate.Month.ToString), CInt(StartDate.SelectedDate.Day.ToString), 0, 0, 0)
Try
XMLDoc = Session("pp.xml")
Dim sw As StringWriter = New StringWriter
Dim XsltParams As New XsltArgumentList
XsltParams.AddParam("sortBy", "", field)
XsltParams.AddParam("sortDirection", "", direction)
XsltParams.AddParam("sortType", "", dataType)
XSLTDoc = New XslTransform
XSLTDoc.Load(Server.MapPath("PlayerPerfomanceSort.xslt"))
XSLTDoc.Transform(XMLDoc, XsltParams, sw, Nothing)
ResultTable.InnerHtml = sw.ToString()
Catch ex As Exception
End Try
End Sub
best regards,
tonci korsano
Thank you very much !
It seems that this sorting pocedure works for sorting a field, not children Tables of an another table. I need to sort tables !
this:
<ParentTable id="1" >
<coAsig tip="S"></coAsig>
<asigD D_1="B1114"></asigD>
<asigB1 B1_1="1" ></asigB1>
<asigB2 B2_1="0" ></asigB2>
<asigB3 B3_1="10"></asigB3>
<asigB4 B4_1="11" ></asigB4>
</ParentTable >
must be:
<ParentTable id="1" >
<asigB1 B1_1="1" ></asigB1>
<asigB2 B2_1="0" ></asigB2>
<asigB3 B3_1="10"></asigB3>
<asigB4 B4_1="11" ></asigB4>
<asigD D_1="B1114"></asigD>
<coAsig tip="S"></coAsig>
</ParentTable >
Sort by element name:
http://www.stylusstudio.com/xsllist/...post50590.html
Thank you very much both tkorsano and reedy837 !!!
Hello !
Yours code works but it does not return the same xml !
I want a code to return the SAME XML but sorted.
Thank you !
PS. I found samples that returns different formats on output. I want that the output to be the same with the imput, but with elements sorted by their names
Which parser or browser do you use
I saw you use IE Browser
so you can not create an outputfile
when you use a parser you can write a new xml file
e.g
saxon
so you overwrite the input xml-fileQuote:
java -mx250m -ms250m -cp saxon9he.jar;xercesImpl-2.9.1.jar net.sf.saxon.Transform -x:org.apache.xerces.parsers.SAXParser -o:xml-file.xml -s:xml-file.xml -xsl:xsl-file.xml
Browser are viewer of xml files
wiht css , xsl and xsl:fo you can change the form of display
hi there,
i wrote a blog about this sorting xml topic.
it is about a reply i made to this discussion.
it is in the following link http://dotnetflux.blogspot.com/2011/...eters-and.html
it contains an example with explanation of how to sort xml data, and how to transform this sorted xml data into formatted html.
this example uses xslt and visual basic .net.
good luck,
tonci.