Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何将一个xslt文件导入另一个xslt文件_Xml_Xslt_Xslt 1.0 - Fatal编程技术网

Xml 如何将一个xslt文件导入另一个xslt文件

Xml 如何将一个xslt文件导入另一个xslt文件,xml,xslt,xslt-1.0,Xml,Xslt,Xslt 1.0,我正在使用XSLT1.0,我想将一个xslt文件导入另一个xslt文件 下面是一个例子: A.xml 请帮我解决这个问题 提前非常感谢。您已经回答了自己的问题xsl:import,因此您当前尝试的内容将无法工作。当您使用xsl:import时,XSLT处理器会将其替换为href属性中命名的样式表的内容,因此在您的情况下,您将使用如下XSLT <xsl:template match="/"> <userData> <

我正在使用XSLT1.0,我想将一个xslt文件导入另一个xslt文件

下面是一个例子:

A.xml

请帮我解决这个问题


提前非常感谢。

您已经回答了自己的问题<在
xsl:template
中不允许使用code>xsl:import,因此您当前尝试的内容将无法工作。当您使用
xsl:import
时,XSLT处理器会将其替换为href属性中命名的样式表的内容,因此在您的情况下,您将使用如下XSLT

    <xsl:template match="/">
         <userData>
              <xsl:template match="/">
                  <header>
因此,在上面的示例中使用
xsl:apply imports
时,它实际上将匹配导入的
a.xml
文件中的主模板

有关详细信息,请参阅。

我厌倦了以下代码,其中docrootPath=c:/test/testdata,但给出了错误:元素类型“xsl:variable”后面必须跟属性规范“>”或“/>”。我也试过了,但它给了我:样式表文件有IO异常。请建议。
   <?xml version="1.0" encoding="UTF-8"?>
     <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       version="1.0">
         <xsl:template match="/">
             <userData>
                <xsl:import href="A.xsl"/>
                  <body>
                     <UserAddress>
                        <xsl:value-of select="'India'" />
                     </UserAddress>
                     <UserPhoneNumber>
                        <xsl:value-of select="'123456789'" />
                     </UserPhoneNumber>
                  </body>
              </userData>
         </xsl:template>
     </xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
 <xsl:template match="/">
    <userData>
        <header>
            <UserId>
                <xsl:value-of select="'user1'" />
            </UserId>
            <UserPaassword>
                <xsl:value-of select="'1234'" />
            </UserPaassword>
        </header>
        <body>
            <UserAddress>
                <xsl:value-of select="'India'" />
            </UserAddress>
            <UserPhoneNumber>
                <xsl:value-of select="'123456789'" />
            </UserPhoneNumber>
        </body>
      </userData>
  </xsl:template>
I tried with the import statement but xsl:import is not allowed into xsl:template.
    <xsl:template match="/">
         <userData>
              <xsl:template match="/">
                  <header>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:import href="A.xml"/>
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
    <userData>
      <xsl:apply-imports />
      <body>
        <UserAddress>
          <xsl:value-of select="'India'" />
        </UserAddress>
        <UserPhoneNumber>
          <xsl:value-of select="'123456789'" />
        </UserPhoneNumber>
      </body>
    </userData>
  </xsl:template>
</xsl:stylesheet>