XML ドキュメントを変換したいと考えています。私の XSLT コードは機能しており、正しく変換されます (XMLPad でテスト済み) が、VB.NET プログラムで変換したいと考えています。.xsl
問題は、ファイルから XSLT コードをロードしたくないということです。関数にハードコードされていますが、Illegal characters in path
例外が発生しています。
そのようにすることは可能ですか:
Public Class xsltTransformCode
Public Function transformationXSLTcode() As String
Return "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>" &
"<xsl:strip-space elements='*'/>" &
"<xsl:output method='xml' indent='yes'/>" &
"<xsl:key name='AreaByPosition' match='Area' use='Position'/>" &
"<xsl:template match='@*|node()'>" &
"<xsl:copy><xsl:apply-templates select='@*|node()'/></xsl:copy>" &
"</xsl:template>" &
"<!-- for the first Area in each Position -->" &
"<xsl:template match='Area[generate-id() = generate-id(key('AreaByPosition', Position)[1])]'>" &
"<Area>" &
"<!-- copy in the Position element once only -->" &
"<xsl:apply-templates select='Position'/>" &
"<!-- copy in all sub-elements except Position from all matching Areas -->" &
"<xsl:apply-templates select='key('AreaByPosition', Position)/*[not(self::Position)]'/>" &
"</Area>" &
"</xsl:template>" &
"<!-- ignore all other Area elements -->" &
"<xsl:template match='Area'/>" &
"</xsl:stylesheet>"
End Function
End Class
ロードしようとすると例外が発生するため
Dim xsltTransformerCode As New xsltTransformCode()
Dim xsltTransCompiled As New XslCompiledTransform()
xsltTransCompiled.Load(xsltTransformerCode.transformationXSLTcode())