Xml 在XSL转换中找不到路径
这是一个后续问题。我复制了下面的原始问题 我做了上述更改,但xsltproc似乎找不到b.xml,尽管a.xml和b.xml在同一个文件夹中。我直接从同一个文件夹调用xsltproc。也许我的电话不对。我曾经Xml 在XSL转换中找不到路径,xml,xslt,Xml,Xslt,这是一个后续问题。我复制了下面的原始问题 我做了上述更改,但xsltproc似乎找不到b.xml,尽管a.xml和b.xml在同一个文件夹中。我直接从同一个文件夹调用xsltproc。也许我的电话不对。我曾经 xsltproc -v --debug -o output.xml merge3.xsl a.xml 其中merge3.xsl是您的(改编)示例。我知道--debug和-v不是必需的,但我想看看xsltproc在做什么 不幸的是,output.xml是a.xml的精确副本 XSLT中的“
xsltproc -v --debug -o output.xml merge3.xsl a.xml
其中merge3.xsl是您的(改编)示例。我知道--debug和-v不是必需的,但我想看看xsltproc在做什么
不幸的是,output.xml是a.xml的精确副本
XSLT中的“ns1”是什么意思?我想知道我的路径是否设置正确。我想ns1是我调用的一个参数。但是哪一个呢
即使我使用所有文件的完整路径,我也只能得到一个.xml的副本。错在哪里
这是merge3.xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="http://tempuri.org/List.xsd">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="doc2" select="'b.xml'" />
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ns1:Record_Count">
<xsl:copy>
<xsl:value-of select=". + document($doc2)/ns1:List/ns1:publshInformation/ns1:Record_Count" />
</xsl:copy>
</xsl:template>
<xsl:template match="ns1:List">
<xsl:copy>
<xsl:apply-templates select="*|document($doc2)/ns1:List/ns1:Entry">
<xsl:sort select="ns1:uid" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
这是最初的问题: 我一直在寻找解决我问题的办法。我发现了一些类似的问题和答案,但没有一个适合我的问题 我是XML新手,以前从未使用过XSLT。我有Linux,可以使用xsltproc或xmllint(或任何最好的) 这个问题相当容易。我必须使用相同布局的XML文件。开头是一个文件中包含的节点计数器。我只需要添加两个文件的计数器,然后将两个文件中的所有节点作为一个列表。(那就更好了。) 例如: a、 xml
12/17/2014
115
9639
上下快速移动
....
b、 xml
12/17/2014
100
4711
约翰
....
结果:
out.xml
12/17/2014
215
4711
约翰
....
9639
上下快速移动
....
我该怎么办?我不在这里发布XSLT,因为它们不起作用,这是因为我的技能有限。谢谢你的建议
ns1
是为URL声明的命名空间前缀。奇怪的是,它与指向XSD的URI相关。请同时显示输入XML。请在此处查看输入XML:最好将其添加到同一篇文章中:)完成。请参见上面的问题。我已将您提供的示例文件与xsltproc一起使用,结果包含215
,因此添加了值,并且在输出中有两个Entry
元素,我不确定您的系统出了什么问题。仔细检查您的文件和路径。
<?xml version="1.0" standalone="yes"?>
<List xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/List.xsd">
<publshInformation>
<Publish_Date>12/17/2014</Publish_Date>
<Record_Count>115</Record_Count>
</publshInformation>
<Entry>
<uid>9639</uid>
<firstName>Bob</firstName>
....
</Entry>
</List>
<?xml version="1.0" standalone="yes"?>
<List xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/List.xsd">
<publshInformation>
<Publish_Date>12/17/2014</Publish_Date>
<Record_Count>100</Record_Count>
</publshInformation>
<Entry>
<uid>4711</uid>
<firstName>John</firstName>
....
</Entry>
</List>
<?xml version="1.0" standalone="yes"?>
<List xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/List.xsd">
<publshInformation>
<Publish_Date>12/17/2014</Publish_Date>
<Record_Count>215</Record_Count>
</publshInformation>
<Entry>
<uid>4711</uid>
<firstName>John</firstName>
....
</Entry>
<Entry>
<uid>9639</uid>
<firstName>Bob</firstName>
....
</Entry>
</List>