I am working on a JavaFX application and I have an xml file that I want to convert to html. The xml file has some elements that have the same attribute name but the child names are different. I want to group the child elements according to the parent element with the same attribute value.
The xml file looks like this:
<?xml version="1.0" encoding="UTF-8" ?> <application> <workflow name="Model Structure"> <name>Model Structure</name> <source>Model data</source> <type>Aleatory</type> <condition>independet</condition> <distribution>None</distribution> <assumptions>onsdn</assumptions> </workflow> <workflow name="Model Structure"> <name>Model Structure</name> <source>Poor data</source> <type>Aleatory</type> <condition>independet</condition> <distribution>GLC</distribution> <assumptions>nsisodsd</assumptions> </workflow> </application
I want the output to be like the following:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <h3>Model Structure</h3> <ol type="1"> <li> <p>Source: Model data</p> <p>Type: Aleatory</p> <p>Conditions: Independent</p> <p>Distribution: GLV</p> <p>Assumptions: sibsdisbdibs</p> </li> <li> <p>Source: Poor data</p> <p>Type: Epistemic with probabilities</p> <p>Conditions: Independent</p> <p>Distribution: GLV</p> <p>Assumptions: sibsdisbdibs</p> </li> </ol> </body> </html>
I am using a for each statement in an xsl stylesheet but I cannot find a good way to check the value of the next element in the iteration and avoid printing it in the html file.
<xsl:value-of select="@*" /> <xsl:for-each select="application/workflow"> <xsl:variable name="tempname"> <xsl:value-of select="name" /></xsl:variable> <h3> <xsl:value-of select="@name"/> </h3> <ol type="1"> <ul> <p>Source: <xsl:value-of select="source" /> </p> <p>Type: <xsl:value-of select="type" /> </p> <p>Conditions: <xsl:value-of select="condition" /> </p> <p>Distribution: <xsl:value-of select="distribution" /> </p> <p>Assumptions: <xsl:value-of select="assumptions" /> </p> </ul> </ol> </xsl:for-each>
No comments:
Post a Comment