XSLT解释cdata并写入文件 [英] XSLT interpret cdata and write to file
问题描述
我有这样的情况:
<List>
<Entry>
<![CDATA[......]]>
</Entry>
<Entry>
<![CDATA[......]]>
</Entry>
...
</List>
CDATA节包含编码的字节。每个条目的cdata都有一个控制字作为第一个字,它描述了要进入文件的数据长度以及要查找的文件长度。例如:
00060000abcdef
表示一个包含 abcdef且长度为6的文件,其查找位置为0。输出应该是一个包含abcdef的文件。
CDATA sections contain encoded bytes. Each entry's cdata has a control word as the first word, that describes what length of the data will go into a file and how much to seek into that file. For example: 00060000abcdef will imply a file that contains "abcdef" and of length 6 seeking at 0. The output should be a file that contains abcdef.
XSLT是通过某种方式解释CDATA并写入文件的正确选择吗?
Is XSLT the right choice to interpret CDATA in a certain way and write to a file?
- 我可以想到使用重定向:在Xalan中编写
-
使用某种自定义XSLT函数,该函数将分解为解析器处理程序来处理:
- I can think of using redirect:write as in Xalan
Use some sort of custom XSLT function that will break into a parser handler to handle this:
<xsl:MyFunc></xsl:MyFunc>
是否可以使用for,if等将自定义XSLT函数编写为标记?
Is there a way to write custom XSLT functions as tags using for, if etc.?
根据Dimitre Novatchev的反馈进行编辑:
Editing after Dimitre Novatchev's feedback:
谢谢为回应!我希望以下内容可以澄清这个问题。抱歉。
Thank you for the response! I hope the below clarifies the question. Sorry.
输入XML文件:
<File>
<Chunk>
<Offset>200</Offset>
<Length>100</Length>
<Data>
<![CDATA[data bytes that can be greater than 100 too, but first 100 is valid.]]>
</Data>
</Chunk>
...
</File>
输出应为具有以下内容的html文件:
The output should be a html file that has this:
<html>
<body>
<a href="resulting_file">file</a>
</body>
</html>
推荐答案
- XSLT是否是以某种方式解释CDATA并将
写入文件的正确选择?
-
是的,CDATA只是文本节点(的一部分),并且像其他任何文本节点一样被处理。
Yes, CDATA is just a (part of a) text node and is processed as any other text node.
是的,XSLT 2.0 xsl:result-document
指令是用来写入(可能有很多不同的)文件。
Yes, the XSLT 2.0 xsl:result-document
instruction is used to write to (possibly many different) file(s).
.2 。使用某种自定义XSLT函数,该函数将分解为解析器
处理程序来处理此问题:
.2. Use some sort of custom XSLT function that will break into a parser handler to handle this:
< xsl:MyFunc>< ; / xsl:MyFunc>
是的,这是使用标准XSLT 2.0指令完成的 xsl:function
Yes, this is done using the standard XSLT 2.0 instruction xsl:function
3.Is there a way to write custom XSLT functions as tags using for, if etc.?
此问题不清楚。 XSLT有很多这样的说明,例如 xsl:for-each
, xsl:if
, xsl:choose
, xsl:when
, xsl:other ,.. ,等等。
This question isn't clear. XSLT has many such instructions, like xsl:for-each
, xsl:if
, xsl:choose
, xsl:when
, xsl:otherwise
, ... etc.
XPath 2.0(在XSLT 2.0中使用)x本身是的
,如果
然后
else
,返回
子句。
XPath 2.0 (which is used within XSLT 2.0) xas its own for
, if
then
else
, return
clauses.
这篇关于XSLT解释cdata并写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!