Expand|Select|Wrap|Line Numbers
- <root name="PlanRepository">
- <directory name="connoraj">
- <directory name="single_run1">
- <file>insidebox.txt</file>
- <file>outsidebox.txt</file>
- <directory name="SAFE_Input">
- <file>leapseconds.txt</file>
- <file>single_run.dat</file>
- <directory name="LeoInputs">
- <file>control_earth.txt</file>
- <file>leo_sc_prop2.txt</file>
- </directory>
- </directory>
- <directory name="SAFE_Output">
- <file>single_run.aer.dat</file>
- <file>single_run.control_files</file>
- <file>single_run.dv.dat</file>
- <file>single_run.est_pv.dat</file>
- <file>single_run.host_ephem.e</file>
- <file>single_run.host_inertial.dat</file>
- <file>single_run.residuals.dat</file>
- <file>single_run.tar_ephem.e</file>
- <file>single_run.tar_inertial.dat</file>
- <file>single_run.true_pv.dat</file>
- </directory>
- </directory>
- </directory>
- </root>
What I'm attempting to do is, within each directory, sort its respective files by their file extensions. The problem is, that in the "SAFE_Output" directory, each filename has 2 "."s in it, which is making a standard way of sorting very difficult. I have come across different types of solutions, but all either don't sort the SAFE_Output folder correctly or add extra files to the nodes.
Using the following XSL:
Expand|Select|Wrap|Line Numbers
- <xsl:template match="root">
- <root name="PlanRepository">
- <br/>
- <xsl:apply-templates />
- </root>
- </xsl:template>
- <xsl:template match="directory">
- <directory name="<xsl:value-of select="@name"/>">
- <br/>
- <xsl:choose>
- <xsl:when test="@name = 'SAFE_Output'">
- <xsl:for-each select="file">
- <xsl:sort select="substring-after(substring-after(.,'.'),'.')" />
- <file><xsl:value-of select="."/></file>
- <br/>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:for-each select="file">
- <xsl:sort select="substring-after(.,'.')" />
- <file><xsl:value-of select="."/></file>
- <br/>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:apply-templates/>
- </directory>
- <br/>
- </xsl:template>
Expand|Select|Wrap|Line Numbers
- <root name="PlanRepository">
- <directory name="connoraj">
- <directory name="single_run.dat.07-10-2007.01-50-22">
- <file>insidebox.txt</file>
- <file>outsidebox.txt</file>
- insidebox.txtoutsidebox.txt
- <directory name="SAFE_Input">
- <file>single_run.dat</file>
- <file>leapseconds.txt</file>
- leapseconds.txtsingle_run.dat
- <directory name="LeoInputs">
- <file>control_earth.txt</file>
- <file>leo_sc_prop2.txt</file>
- control_earth.txtleo_sc_prop2.txt
- </directory>
- </directory>
- <directory name="SAFE_Output">
- <file>single_run.control_files</file>
- <file>single_run.aer.dat</file>
- <file>single_run.dv.dat</file>
- <file>single_run.est_pv.dat</file>
- <file>single_run.host_inertial.dat</file>
- <file>single_run.residuals.dat</file>
- <file>single_run.tar_inertial.dat</file>
- <file>single_run.true_pv.dat</file>
- <file>single_run.host_ephem.e</file>
- <file>single_run.tar_ephem.e</file>
- single_run.aer.datsingle_run.control_filessingle_run.dv.datsingle_run.est_pv.datsingle_run.host_ephem.esingle_run.host_inertial.datsingle_run.residuals.datsingle_run.tar_ephem.esingle_run.tar_inertial.datsingle_run.true_pv.dat
- </directory>
- </directory>
- </directory>
- </root>
Thanks