Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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

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 在浏览器中查看xsl的输出_Xml_Xslt - Fatal编程技术网

Xml 在浏览器中查看xsl的输出

Xml 在浏览器中查看xsl的输出,xml,xslt,Xml,Xslt,我有一个xml文件。我想通过xsl更改一些xml元素的样式。所以我也有一个xsl文件。然后我想在浏览器中查看更改,但我不知道如何才能做到这一点 xml文件:(test.xml) xsl文件:(test.xsl) Arial 真的 红色 桑 真的 将test.xml和test.xsl放在同一目录中,然后在浏览器中加载test.xml——开头的?xml样式表指令将导致浏览器加载并执行xsl 话虽如此,应用于XML测试文件的XSL将生成以下输出: <Text Font="Arial" Bo

我有一个xml文件。我想通过xsl更改一些xml元素的样式。所以我也有一个xsl文件。然后我想在浏览器中查看更改,但我不知道如何才能做到这一点

xml文件:(test.xml)


xsl文件:(test.xsl)


Arial
真的
红色
桑
真的

test.xml
test.xsl
放在同一目录中,然后在浏览器中加载
test.xml
——开头的
?xml样式表
指令将导致浏览器加载并执行xsl

话虽如此,应用于XML测试文件的XSL将生成以下输出:

<Text Font="Arial" Bold="true" Color="Red"></Text>
<Text Font="Sans" Italic="true"></Text>

无法在浏览器中查看输出吗?我想通过此属性(Arial、粗体、红色)查看style1。当我尝试在本地硬盘上加载文件时,我尝试在Chrome上加载URL,但不安全:(
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes"/>
    <xsl:output method="html"/>
    <xsl:attribute-set name="style1">
        <xsl:attribute name="Font">Arial</xsl:attribute>
        <xsl:attribute name="Bold">true</xsl:attribute>
        <xsl:attribute name="Color">Red</xsl:attribute>
    </xsl:attribute-set>
    <xsl:attribute-set name="style2">
        <xsl:attribute name="Font">Sans</xsl:attribute>
        <xsl:attribute name="Italic">true</xsl:attribute>
    </xsl:attribute-set>
    <xsl:template match="Text[@Style='style1']">
        <xsl:copy use-attribute-sets="style1">
            <xsl:copy-of select="@*[name()!='Style']"/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="Text[@Style='style2']">
        <xsl:copy use-attribute-sets="style2">
            <xsl:copy-of select="@*[name()!='Style']"/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
<Text Font="Arial" Bold="true" Color="Red"></Text>
<Text Font="Sans" Italic="true"></Text>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes"/>
  <xsl:output method="html"/>

  <xsl:template match="Text[@Style='style1']">
    <p style="font-family: Arial; font-weight: bold; color: red">
      <xsl:apply-templates/>
    </p>
  </xsl:template>

  <xsl:template match="Text[@Style='style2']">
    <p style="font-family: Sans-Serif; font-style: italic">
      <xsl:apply-templates/>
    </p>
  </xsl:template>

</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test2.xsl"?>
<root>
  <Text Style='style1'>Text in style 1</Text>
  <Text Style='style2'>Text in style 2</Text>
</root>