philipHaugaard
asked on
XslTransform is removeing tag
Hello Experts
first time i try to use this so here goes:
I have made a tiny program in VB.net that takes an XML file and apply an XSTL to that file.
the problem is that whenever i try to run the XSLT that looks like:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="x si">
<xsl:output method="xml" encoding="UTF-8" doctype-system="sample.dtd "/>
<xsl:template match="/data">
<data>
<xsl:for-each select="dbo.Proever">
<dbo.Proeve>
<xsl:for-each select="@proeveID">
<proeveID>
<xsl:value-of select="."/>
</proeveID>
......snip
<xsl:for-each select="@metaGruppe">
<metaGruppe>
<xsl:value-of select="."/>
</metaGruppe>
</xsl:for-each>
</dbo.RNR>
</xsl:for-each>
</dbo.Proeve>
</xsl:for-each>
</data>
</xsl:template>
</xsl:stylesheet>
its a rather long xslt file so i have not pasted it all. the problem is that after running this code:
Public Sub ReadTransformWrite()
Try
Dim xpathdocument As New XPathDocument(OpenFileDial og1.FileNa me)
Dim xslt As New XslTransform
xslt.Load(OpenFileDialog2. FileName)
Dim writer As New XmlTextWriter(SaveFileDial og1.FileNa me, System.Text.Encoding.UTF8)
writer.Formatting = Formatting.Indented
xslt.Transform(xpathdocume nt, Nothing, writer, Nothing)
writer.Close()
Label1.Text = "Processing complete"
Catch e As Exception
Label1.Text = "Processing Aborted due to Error"
End Try
End Sub
the program output looks like this:
<data>
<dbo.Proeve>
<proeveID>1498</proeveID>
<Analysenavn>C'-funktion, C3, C4, C5, C3 nephr.fact.</Analysenavn>
<Artikelnr>48579</Artikeln r>
and it have not written out the the <?xml version="1.0" encoding="UTF-8"?> that the output should have started with.
i am quite boggled by this and cant find out why this is so. i could ofcource rewrite the output file and just hardcode the <?xml version="1.0" encoding="UTF-8"?> at the top but i would like to make the program generic so its really not an option.
Thank you for your time
Philip
first time i try to use this so here goes:
I have made a tiny program in VB.net that takes an XML file and apply an XSTL to that file.
the problem is that whenever i try to run the XSLT that looks like:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="x
<xsl:output method="xml" encoding="UTF-8" doctype-system="sample.dtd
<xsl:template match="/data">
<data>
<xsl:for-each select="dbo.Proever">
<dbo.Proeve>
<xsl:for-each select="@proeveID">
<proeveID>
<xsl:value-of select="."/>
</proeveID>
......snip
<xsl:for-each select="@metaGruppe">
<metaGruppe>
<xsl:value-of select="."/>
</metaGruppe>
</xsl:for-each>
</dbo.RNR>
</xsl:for-each>
</dbo.Proeve>
</xsl:for-each>
</data>
</xsl:template>
</xsl:stylesheet>
its a rather long xslt file so i have not pasted it all. the problem is that after running this code:
Public Sub ReadTransformWrite()
Try
Dim xpathdocument As New XPathDocument(OpenFileDial
Dim xslt As New XslTransform
xslt.Load(OpenFileDialog2.
Dim writer As New XmlTextWriter(SaveFileDial
writer.Formatting = Formatting.Indented
xslt.Transform(xpathdocume
writer.Close()
Label1.Text = "Processing complete"
Catch e As Exception
Label1.Text = "Processing Aborted due to Error"
End Try
End Sub
the program output looks like this:
<data>
<dbo.Proeve>
<proeveID>1498</proeveID>
<Analysenavn>C'-funktion, C3, C4, C5, C3 nephr.fact.</Analysenavn>
<Artikelnr>48579</Artikeln
and it have not written out the the <?xml version="1.0" encoding="UTF-8"?> that the output should have started with.
i am quite boggled by this and cant find out why this is so. i could ofcource rewrite the output file and just hardcode the <?xml version="1.0" encoding="UTF-8"?> at the top but i would like to make the program generic so its really not an option.
Thank you for your time
Philip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
no problem =)
ASKER
Works just like it should :)
Not really in my opinion the work of the writer but i cant really blame the expert that came with the solution for that ;)
Best Regards
Philip
Not really in my opinion the work of the writer but i cant really blame the expert that came with the solution for that ;)
Best Regards
Philip
lol =)
ASKER
well ill be back to work monday and give the solution a try. Ill write if it worked
Thanks for your time
Philip