将iso xsl转换为svrl xsl

时间:2020-09-29 11:25:33

标签: xml xslt

我不知道这是不是真的。我有一个iso xsl文件, 我想将其转换为svrl xsl文件。因为我可以使用svrl xsl文件进行schematron检查。

我正在我提到的iso xsl和svrl xsl文件中添加示例代码片段 我应该遵循哪种解决方案?谢谢

简单的iso xsl;

 <xsl:template match="sh:StandardBusinessDocument" priority="1000" mode="M23">
        <!--ASSERT -->
      <xsl:choose>
         <xsl:when test="sh:StandardBusinessDocumentHeader"/>
         <xsl:otherwise>
            <xsl:message xmlns:iso="http://purl.oclc.org/dsdl/schematron">
               <xsl:text>sh:StandardBusinessDocumentHeader is required.</xsl:text>
            </xsl:message>
         </xsl:otherwise>
      </xsl:choose>
      <!--ASSERT -->
      <xsl:choose>
         <xsl:when test="ef:Package"/>
         <xsl:otherwise>
            <xsl:message xmlns:iso="http://purl.oclc.org/dsdl/schematron">
               <xsl:text>ef:Package is required.</xsl:text>
            </xsl:message>
         </xsl:otherwise>
      </xsl:choose>
      <!--ASSERT -->
      <xsl:choose>
         <xsl:when test="contains(@xsi:schemaLocation,'PackageProxy_1_2.xsd')"/>
         <xsl:otherwise>
            <xsl:message xmlns:iso="http://purl.oclc.org/dsdl/schematron">
               <xsl:text>sh:StandardBusinessDocument xsi:schemaLocation must be 'PackageProxy_1_2.xsd'</xsl:text>
            </xsl:message>
         </xsl:otherwise>
      </xsl:choose>
      <!--ASSERT -->
      <xsl:choose>
         <xsl:when test="not(name()= 'Invoice') or string-length(normalize-space(string(namespace::xsi))) != 0"/>
         <xsl:otherwise>
            <xsl:message xmlns:iso="http://purl.oclc.org/dsdl/schematron">
               <xsl:text>Invoice element and xmlns: xsi attribute with no null values. </xsl:text>
            </xsl:message>
         </xsl:otherwise>
      </xsl:choose>
      <xsl:apply-templates select="@*|*" mode="M23"/>
   </xsl:template>

简单的svrl xsl;

     <xsl:template match="sh:StandardBusinessDocument" mode="M20" priority="1000">
    <svrl:fired-rule context="sh:StandardBusinessDocument" xmlns:svrl="http://purl.oclc.org/dsdl/svrl"/>
    <!--ASSERT -->
    <xsl:choose>
      <xsl:when test="sh:StandardBusinessDocumentHeader"/>
      <xsl:otherwise>
        <svrl:failed-assert test="sh:StandardBusinessDocumentHeader" xmlns:svrl="http://purl.oclc.org/dsdl/svrl">
          <xsl:attribute name="location">
            <xsl:apply-templates mode="schematron-select-full-path" select="."/>
          </xsl:attribute>
          <svrl:text>sh:StandardBusinessDocumentHeader is required.</svrl:text>
        </svrl:failed-assert>
      </xsl:otherwise>
    </xsl:choose>
    <!--ASSERT -->
    <xsl:choose>
      <xsl:when test="ef:Package"/>
      <xsl:otherwise>
        <svrl:failed-assert test="ef:Package" xmlns:svrl="http://purl.oclc.org/dsdl/svrl">
          <xsl:attribute name="location">
            <xsl:apply-templates mode="schematron-select-full-path" select="."/>
          </xsl:attribute>
          <svrl:text>ef:Package is required.</svrl:text>
        </svrl:failed-assert>
      </xsl:otherwise>
    </xsl:choose>
    <!--ASSERT -->
    <xsl:choose>
      <xsl:when test="contains(@xsi:schemaLocation,'PackageProxy_1_2.xsd')"/>
      <xsl:otherwise>
        <svrl:failed-assert test="contains(@xsi:schemaLocation,'PackageProxy_1_2.xsd')" xmlns:svrl="http://purl.oclc.org/dsdl/svrl">
          <xsl:attribute name="location">
            <xsl:apply-templates mode="schematron-select-full-path" select="."/>
          </xsl:attribute>
          <svrl:text>sh:StandardBusinessDocument xsi:schemaLocation must be 'PackageProxy_1_2.xsd'</svrl:text>
        </svrl:failed-assert>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates mode="M20" select="@*|*|comment()|processing-instruction()"/>
  </xsl:template>

0 个答案:

没有答案