Xslt 转换并组合*.xml
我想从xml文件中提取一系列关系,并将它们转换为我用点生成的图形。显然,我可以用脚本语言实现这一点,但我很好奇xslt是否可以实现这一点。比如:Xslt 转换并组合*.xml,xslt,Xslt,我想从xml文件中提取一系列关系,并将它们转换为我用点生成的图形。显然,我可以用脚本语言实现这一点,但我很好奇xslt是否可以实现这一点。比如: xsltproc dot.xsl *.xml 这会产生一个像 diagraph { state -> state2 state2 -> state3 [More state relationships from *.xml files] } 因此,我需要1)用“diagraph{…}”包装组合的xml转换,2)能够处理命令行上指定
xsltproc dot.xsl *.xml
这会产生一个像
diagraph {
state -> state2
state2 -> state3
[More state relationships from *.xml files]
}
因此,我需要1)用“diagraph{…}”包装组合的xml转换,2)能够处理命令行上指定的任意xml文档集
这可能吗?有什么建议吗 使用处理器和函数这真的很容易
下面是使用的示例:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="pDirName" select="'D:/Temp/xmlFilesDelete'"/>
<xsl:template match="/">
<wrap>
<xsl:apply-templates select=
"collection(
concat('file:///',
$pDirName,
'?select=*.xml;recurse=yes;on-error=ignore'
)
)/*
"/>
</wrap>
</xsl:template>
<xsl:template match="*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
<wrap>
<apples>3</apples>
<oranges>3</oranges>
</wrap>
及
3
生成正确的结果:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="pDirName" select="'D:/Temp/xmlFilesDelete'"/>
<xsl:template match="/">
<wrap>
<xsl:apply-templates select=
"collection(
concat('file:///',
$pDirName,
'?select=*.xml;recurse=yes;on-error=ignore'
)
)/*
"/>
</wrap>
</xsl:template>
<xsl:template match="*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
<wrap>
<apples>3</apples>
<oranges>3</oranges>
</wrap>
您可能需要查看()。它使用xslt从xml文档生成点语法。您的示例不完整。xml文件的expexted格式是什么,应该从中生成什么,结果应该如何组合?请提供一个完整但尽可能少的示例。