Document()XSLT 2.0无法访问xml子元素(Saxon CE 1.1)

时间:2017-05-28 14:12:32

标签: xml xslt-2.0 saxon

我有一个样式表,在检索这个xml文件之后使用document()函数加载XML文件我无法访问它的任何子元素,我唯一可以得到的就是洞文档:文档('参数')将显示漏洞文档内容,但在调用文档时('参数')/ total_time则不会显示

XML文档

<?xml version="1.0" encoding="utf-8"?>
<parameters 
xmlns="http://www.duniptechnologies.com/binding/Coupled" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="
http://www.duniptechnologies.com/binding/Coupled/parameters.xsd">
<total_time>100.2</total_time>
<external_events>
    <event>
        <message>go to red</message>
        <model>red_light</model>
        <port>15</port>
        <time>150</time>
    </event>
    <event>
        <message>go to red</message>
        <model>red_light</model>
        <port>15</port>
        <time>180</time>
    </event>
</external_events>
<Initialization>
    <model name="Atomic1">Atomic1</model>
    <model name="Atomic2">Atomic2</model>
    <model name="Coupled">Coupled</model>
    <model name="SousAtomic1">SousAtomic1</model>
    <model name="SousCoupled1">SousCoupled1</model>
    <model name="SouSouAtomic1">SouSouAtomic1</model>
</Initialization>
</parameters>

XSLT文档

<xsl:stylesheet xpath-default-
namespace="http://www.duniptechnologies.com/binding/Coupled" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:prop="http://saxonica.com/ns/html-property" 
xmlns:style="http://saxonica.com/ns/html-style-property" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT" 
xmlns:js="http://saxonica.com/ns/globalJS" extension-element-prefixes="ixsl" 
version="2.0">
<xsl:template match("/rootelemnt")>
    <xsl:value-of select="document('parameters.xml')/total_time/text()"/>
</xsl:template>
</xsl:stylesheet>

校正

替换

<xsl:value-of select="document('parameters.xml')/total_time/text()"/>

通过

<xsl:value-of select="document('parameters.xml')/parameters/total_time/text()"/>

0 个答案:

没有答案