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转换错误_Xml_Xslt - Fatal编程技术网

Xml XSLT转换错误

Xml XSLT转换错误,xml,xslt,Xml,Xslt,我对XML和XSLT非常陌生。我正在尝试使用xslt“转换”xml文档。不幸的是,这是不正确的工作。在尝试加载xml文件时,我在FireFox中遇到以下错误“XSLT转换期间出错:XSLT转换失败”。Chrome只加载一个空页面。XML和XSLT文件都独立加载到浏览器中,这表明它们都是格式良好的。以下是XSL文件: <wb:stylesheet version="3.0" xmlns:wb="http://www.w3.org/1999/XSL/Transform"> <wb

我对XML和XSLT非常陌生。我正在尝试使用xslt“转换”xml文档。不幸的是,这是不正确的工作。在尝试加载xml文件时,我在FireFox中遇到以下错误“XSLT转换期间出错:XSLT转换失败”。Chrome只加载一个空页面。XML和XSLT文件都独立加载到浏览器中,这表明它们都是格式良好的。以下是XSL文件:

<wb:stylesheet version="3.0"
xmlns:wb="http://www.w3.org/1999/XSL/Transform">

<wb:template match="/">
  <html>
  <body>
    <h2>Name: <wb:value-of select="wb:world/wb:name" /></h2>
    <p><wb:vlaue-of select="wb:world/wb:desc" /></p>
  </body>
  </html>
</wb:template>

</wb:stylesheet>

姓名:

下面是XML文件:

<wb:stylesheet version="3.0"
xmlns:wb="http://www.w3.org/1999/XSL/Transform">

<wb:template match="/">
  <html>
  <body>
    <h2>Name: <wb:value-of select="wb:world/wb:name" /></h2>
    <p><wb:vlaue-of select="wb:world/wb:desc" /></p>
  </body>
  </html>
</wb:template>

</wb:stylesheet>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="./world.xsl"?>
<world
xmlns:wb="http://www.w3.org/2001/XMLSchema-instance" 
wb:schemaLocation="./ world.xsd">
    <wb:name>Arizelos</wb:name>
    <wb:desc>
    </wb:desc>
    <wb:nation>
        <wb:name>Whatever</wb:name>
        <wb:map>map01.png</wb:map>
        <wb:number>1</wb:number>
        <wb:desc>Whatever</wb:desc>     
        <wb:county>
            <wb:name>Whatever</wb:name>
            <wb:size>City-State</wb:size>
            <wb:number>1</wb:number>
            <wb:desc>Whatever</wb:desc>     
            <wb:community>
                <wb:name>Test</wb:name>
                <wb:size>City</wb:size>
                <wb:number>1</wb:number>
                <wb:desc>Whatever</wb:desc>     
                <wb:profession>
                    <wb:name>Sorcerer</wb:name>
                    <wb:number>1</wb:number>
                    <wb:desc>Whatever</wb:desc>     
                    <wb:person>
                        <wb:name>Harry Potter</wb:name>
                        <wb:number>1</wb:number>
                        <wb:desc>Whatever</wb:desc>
                        <wb:charsheet>
                        </wb:charsheet>
                    </wb:person>
                </wb:profession>
            </wb:community>
        </wb:county>
    </wb:nation>
    <wb:religion>
        <wb:name>Phony</wb:name>
        <wb:desc>But aren't they all?</wb:desc>
        <wb:deity>
            <wb:name>John Doe</wb:name>
            <wb:gender>Male</wb:gender>
            <wb:desc>I never considered him divine</wb:desc>
        </wb:deity>
    </wb:religion>
</world>

阿里塞洛斯
无论什么
map01.png
1.
无论什么
无论什么
城邦
1.
无论什么
试验
城市
1.
无论什么
巫师
1.
无论什么
哈利·波特
1.
无论什么
假的
但他们不都是吗?
无名氏
男性
我从不认为他是神
提前感谢您提供的帮助:)

您的代码有很多问题。让我指出其中一些

在XSLT样式表中

  • 您已经为XSLT命名空间声明了一个非标准前缀:
    xmlns:wb=”http://www.w3.org/1999/XSL/Transform“
    。尽管您可以使用任何您想要的前缀,
    xsl
    实际上是它的标准。其他一切都是令人困惑的
  • 您尚未声明输入XML中存在的命名空间(
    http://www.w3.org/2001/XMLSchema-instance
  • 此外,不幸的是,在XML和XSLT样式表中使用相同的前缀表示不同的命名空间URI
  • 即使
    world
    元素没有名称空间,也可以引用
    wb:world
  • 样式表是3.0版,但浏览器只支持1.0,XSLT 3.0仍然是一个工作草案
  • 有一个输入错误:
    vlaue of
    ,应该是
    xsl:value of
在输入XML中

  • 存在以下命名空间声明:
    xmlns:wb=”http://www.w3.org/2001/XMLSchema-instance“
    。同样,这是一个非标准前缀-您应该使用
    xsi
    。但是,我不确定您是否打算将名称空间用于模式实例
样式表

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wb="http://www.w3.org/2001/XMLSchema-instance">

   <xsl:template match="/">
     <html>
     <body>
       <h2>Name: <xsl:value-of select="world/wb:name" /></h2>
       <p><xsl:value-of select="world/wb:desc" /></p>
     </body>
     </html>
   </xsl:template>

</xsl:stylesheet>

的值拼写不正确。1。另外,在输入XML中,因为您没有指定任何名称空间前缀,但在xpath中使用了前缀。2.在XSLT中使用xpath前缀之前,应该声明名称空间。