0

XslCompiledTransform.Load を使用していますが、毎回エラー メッセージが表示されます。

 'version' cannot be a child  of the 'Transformation' element

これはスタイルシートです:

<Transformation><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts" 
xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"><xsl:output 
method="xml" /><xsl:template match="node() | @*"><xsl:copy><xsl:apply-templates 
select="@* | node()" /></xsl:copy></xsl:template><xsl:template match="testlist"><xsl:copy>
<xsl:apply-templates select="test"><xsl:sort select="requestor/code" /></xsl:apply-   
templates></xsl:copy></xsl:template></xsl:stylesheet></Transformation>

バージョンを削除すると、次のエラーが表示されます:必須属性「バージョン」 がありません タグ「変換」内でスタイルシートを使用しているため、エラーが発生しますか?

4

1 に答える 1

1

あなたの質問に対する答えは「はい」です。xsl:stylesheet要素内にTransformation要素しかないため、エラーが発生します

<Transformation>
   <xsl:stylesheet version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xsl:stylesheetはルート要素であるTransformation必要があるため、削除する必要があります。

そうは言っても、あなたはこれをするつもりだったのかもしれません....

<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
  xmlns:user="urn:my-scripts" 
  xmlns:exsl="http://exslt.org/common" 
  extension-element-prefixes="exsl">
   <xsl:output method="xml"/>

   <xsl:template match="/">
      <Transformation>
         <xsl:apply-templates select="@* | node()"/>
      </Transformation>
   </xsl:template>

   <xsl:template match="node() | @*">
      <xsl:copy>
         <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
   </xsl:template>

   <xsl:template match="testlist">
      <xsl:copy>
         <xsl:apply-templates select="test">
            <xsl:sort select="requestor/code"/>
         </xsl:apply-templates>
      </xsl:copy>
   </xsl:template>
 </xsl:stylesheet>
于 2014-09-11T18:44:36.623 に答える