Cocoon - 管道:使用 XSL 转换 XML 两次?

发布于 2024-08-01 13:06:17 字数 1163 浏览 5 评论 0原文

我的问题是以某种方式设置 Cocoon sitemap.xmap,它首先使用 XSL 对 XML 文件进行转换,然后我可以将其用于我自己的转换。

我有以下文件:

start.xml :包含应用combine_start.xsl 组合在一起的文件的引用。transform.xsl

:这是我自己的XSL 文件,我想将其用于使用combine_start.xsl 进行的转换(输出XML

) start.xml 是该过程中所需的所有文件的索引,如果应用任何 XSL 函数(未找到标签),则以下站点地图不会显示任何结果。 我已经在网上搜索过,但我还没有找到一种方法来设置管道,该管道首先进行转换,然后再应用另一个转换。

希望我的问题不是太令人困惑,我感谢我能得到的任何帮助。 您将在下面找到我尝试过的站点地图。

<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

 <map:pipelines>

  <map:pipeline>

   <map:match pattern="*">
     <map:generate src="start.xml"/>
     <map:transform src="transform.xsl">
             <map:parameter name="X" value="{request-param:X}"/>
             <map:parameter name="Semester" value="{request-param:Semester}"/>
             <map:parameter name="Name" value="{request-param:Name}"/>
             <map:parameter name="XXX" value="{request-param:XXX}"/>
     </map:transform>
     <map:serialize/>
   </map:match>

  </map:pipeline>
 </map:pipelines>
</map:sitemap>

My problem is to setup the Cocoon sitemap.xmap in a way, that it first makes a transformation of an XML file with XSL, which I can then use for my own transformation.

I have following files:

start.xml : Contains references of files which are put together applying combine_start.xsl

transform.xsl: This is my own XSL file which I want to use on the transformation made with the combine_start.xsl (output XML)

Since start.xml is kind of an index for all the files needed in the process, the following sitemap wont show any results, if any XSL functions are applied (no tags are found).
I've search the net, but I havent found a way to setup a pipeline which first makes a transformation, before applying another transformation.

Hopefully my problem istn too confusing and I appreciate any help I can get. Below you'll find the sitemap I tried.

<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">

 <map:pipelines>

  <map:pipeline>

   <map:match pattern="*">
     <map:generate src="start.xml"/>
     <map:transform src="transform.xsl">
             <map:parameter name="X" value="{request-param:X}"/>
             <map:parameter name="Semester" value="{request-param:Semester}"/>
             <map:parameter name="Name" value="{request-param:Name}"/>
             <map:parameter name="XXX" value="{request-param:XXX}"/>
     </map:transform>
     <map:serialize/>
   </map:match>

  </map:pipeline>
 </map:pipelines>
</map:sitemap>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空‖城人不在 2024-08-08 13:06:17

可以多次变换。 只需在序列化之前再次调用map:transform(使用不同的xsl)即可。

您还可以使用 map:part/map:aggregate 将多个匹配器混合在一起,然后对它们应用 map:transform (或 i:include 转换器)。

我真的不知道“找不到标签”是什么意思,所以也许我回答的问题是错误的。

--

如果您想查看调试输出(即基于 xml 生成的内容,您应该使用视图 - 在站点地图中声明它(请参阅:http://cocoon.apache.org/2.0/userdocs/concepts/views.html) 并为你的变压器添加一个标签。然后可以通过调用 url?cocoon-view=YOURLABEL 来准确查看 xsl 使用的数据

You can transform multiple times. just call map:transform again (with a different xsl) - before you serialize.

you can also use map:part/map:aggregate to mash together multiple matcher and then apply a map:transform on them (or the i:include transformer).

I dont really know what you mean with "no tags found", so maybe i am addressing the question wrong.

--

if you want to see debug output (ie. what exactly is generated based on the xml, you should work with views - declare it in the sitemap (see: http://cocoon.apache.org/2.0/userdocs/concepts/views.html) and add a label to your transformer. you can then see exactly what data is being used for the xsl by calling url?cocoon-view=YOURLABEL

一世旳自豪 2024-08-08 13:06:17

迈克尔似乎不再是用户了,但无论如何我都会回答这个问题。 基本上添加代码来说明 Niko 的答案,并且更具体一些。

将transform.xsl应用到combine_start.xsl [ObHalfLife2Reference]的输出的方法是:

   <map:match pattern="*">
     <map:generate src="start.xml"/>
     <map:transform src="combine_start.xsl" />
     <map:transform src="transform.xsl">
             <map:parameter name="X" value="{request-param:X}"/>
             <map:parameter name="Semester" value="{request-param:Semester}"/>
             <map:parameter name="Name" value="{request-param:Name}"/>
             <map:parameter name="XXX" value="{request-param:XXX}"/>
     </map:transform>
     <map:serialize/>
   </map:match>

如果我理解你是说combine_start.xsl的输出是空的,那么这不是一个Cocoon问题而是一个XSLT问题...你的mix_start.xsl 无法正常工作。

鉴于 start.xml 是要输入到transform.xsl中的文件索引, cinclude Transformer 可能是您正在寻找的,而不是实现一个样式表来吸收它们。另一方面,如果 start.xml 的内容永远不会改变,那么如上所述,

会更有效。

Michael doesn't seem to be a user anymore, but I'll answer this anyway. Basically adding code to illustrate to Niko's answer, and being a little more specific.

The way to apply transform.xsl to the output of combine_start.xsl [ObHalfLife2Reference] is:

   <map:match pattern="*">
     <map:generate src="start.xml"/>
     <map:transform src="combine_start.xsl" />
     <map:transform src="transform.xsl">
             <map:parameter name="X" value="{request-param:X}"/>
             <map:parameter name="Semester" value="{request-param:Semester}"/>
             <map:parameter name="Name" value="{request-param:Name}"/>
             <map:parameter name="XXX" value="{request-param:XXX}"/>
     </map:transform>
     <map:serialize/>
   </map:match>

If I understand you to be saying that the output of combine_start.xsl is empty, then that's not a Cocoon issue but an XSLT issue... your combine_start.xsl is not working correctly.

Given that start.xml is an index of files to feed into transform.xsl, the cinclude transformer is probably what you are looking for, rather than implementing a stylesheet to slurp them in. On the other hand if the contents of start.xml will never change, then as mentioned above, <map:aggregate> would be more efficient.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文