webmasterbeta
New Member
Hi, my first steps in XML, so maybe even my concept is not the appropriate one, but let's start at the beginning:
Input:
I've got an XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<publications>
<publication SourceName="Plumtree" SourceUNID="698">
<title>STAT 2003 Q2: Factual</title>
<category>_Hidden_01. Closing Documents -STAT-</category>
<security users="" groups="1,51"/>
</publication>
...
Output:
I need to have an XML file, which is sorted first by category and second by title.
Black Box:
I think I should use XSL, right?
My approach:
Add to the XML: <?xml-stylesheet type="text/xsl" href=http://www.webdeveloper.com/forum/archive/index.php/"sortPublications.xsl"?>
Write an XSL as following:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" encoding="UTF-8" indent="yes"/>
<publications>
<publication>
<xsl:sort select="category"/>
<xsl:sort select="title"/>
<xsl:attribute name="category">
<xsl:value-of select="category"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="title"/>
</xsl:attribute>
<xsl:attribute name="security">
<xsl:attribute name="users">
<xsl:value-of select="users"/>
</xsl:attribute>
<xsl:attribute name="groups">
<xsl:value-of select="groups"/>
</xsl:attribute>
</xsl:attribute>
</publication>
<publication>
</xsl:stylesheet>
But, hmm, XSL does not work as I do... you've got some hints?
Input:
I've got an XML file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<publications>
<publication SourceName="Plumtree" SourceUNID="698">
<title>STAT 2003 Q2: Factual</title>
<category>_Hidden_01. Closing Documents -STAT-</category>
<security users="" groups="1,51"/>
</publication>
...
Output:
I need to have an XML file, which is sorted first by category and second by title.
Black Box:
I think I should use XSL, right?
My approach:
Add to the XML: <?xml-stylesheet type="text/xsl" href=http://www.webdeveloper.com/forum/archive/index.php/"sortPublications.xsl"?>
Write an XSL as following:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" encoding="UTF-8" indent="yes"/>
<publications>
<publication>
<xsl:sort select="category"/>
<xsl:sort select="title"/>
<xsl:attribute name="category">
<xsl:value-of select="category"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="title"/>
</xsl:attribute>
<xsl:attribute name="security">
<xsl:attribute name="users">
<xsl:value-of select="users"/>
</xsl:attribute>
<xsl:attribute name="groups">
<xsl:value-of select="groups"/>
</xsl:attribute>
</xsl:attribute>
</publication>
<publication>
</xsl:stylesheet>
But, hmm, XSL does not work as I do... you've got some hints?