I am trying to sort the data in an xml file before creating reports of the data.
My xml file is like
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE SpringOpen SYSTEM "Seniors_Open.dtd"[]>
<SpringOpen>
<Team>
<FirstName1>Joe</FirstName1>
<Surname1>Soap</Surname1>
<Club1>Man United</Club1>
<TeamNumber>2</TeamNumber>
</Team>
<Team>
<FirstName1>John</FirstName1>
<Surname1>Doe</Surname1>
<Club1>Aintree</Club1>
<TeamNumber>1</TeamNumber>
</Team>
</SpringOpen>
I am trying to sort the data by the element TeamNumber
my XSL file is
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="SpringOpen">
<xsl:copy>
<xsl:apply-templates select="Team">
<xsl:sort select="TeamNumber" data-type="text"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
What I have tried:
My VB.net is
Dim xslt As New XslCompiledTransform()
xslt.Load(Path & "\Spring_Open.xsl")
' Execute the transform and output the results to a file.
xslt.Transform(Path & "\Spring_Open.xml", Path & "\sortedSpring_Open.xml")
The error I get when executing the transform is
System.Xml.XmlException: 'For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.'
Being an absolute novice I do not understand what the error means!
Can anyone help to solve my problem.
I have deleted
<!DOCTYPE SpringOpen SYSTEM "Seniors_Open.dtd"[]>
from my xml file and it now works Why?