gpt4 book ai didi

xml - 如何将节点(任何)发送到 xsl :function?

转载 作者:数据小太阳 更新时间:2023-10-29 01:51:15 24 4
gpt4 key购买 nike

我可以将节点发送到 XSLT 函数吗?例如:

<books>
<book>
<author>a1</author>
<price>10</price>
<year>2009</year>
</book>
<!-- ... -->
</books>

我可以发送 <book> 吗?函数的元素 - 在该函数中我想处理书下的节点( <author><price><year> )

我可以创建如下所示的 xsl:function 吗?

 <xsl:function name="util:checkNode" as="xs:boolean">
<!-- I would like to know xml schema data type for the param -->
<xsl:param name="nodeP" as="****"/>
</xsl:function


If yes, what xsl schema type to the param ?

看起来我用 function 而不是 xsl:function 给每个人造成了很多困惑 ---- :(

最佳答案

我认为您的问题的答案是肯定的。您可以将节点发送到 XSLT 函数。

如果您想知道使用什么作为 as=""属性的值,您有多种选择。如果您想变得非常松散并接受任何东西,请使用 as="item()*"

From David Pawson's site :

item()* .. sort of nodeset? W3C

Yes, I agree it looks pretty meaningless doesn't it. However. As of CR, its pretty essential, especially if you want to use types. And want to generate, say, a nodeset.. sorry sequence, in a variable.

<xsl:variable name="a"
select="(//h3)[position() < 3]"
as="item()*"/>

This creates a variable you can hack into using xpath quite readily. I.e. remember item()*.

types ... a few examples. W3C

From an explanatory email from Mike Kay, thanks Mike. Examples:

<xsl:param name="x" as="item()"/>

the parameter value can be any item (i.e. a node or atomic value). But it must be a single item.

<xsl:param name="x" as="item()?"/>

the parameter can be a single item or an empty sequence

<xsl:param name="x" as="item()+"/>

the parameter must be a sequence of one or more items - an empty sequence is not allowed

<xsl:param name="x" as="item()*"/>

the parameter can be any sequence of zero or more items - this places no constraints on its value.

<xsl:param name="x" as="node()*"/>

the parameter can be any sequence of zero or more nodes

<xsl:param name="x" as="xs:atomicValue*"/>

the parameter can be any sequence of zero or more atomic values (e.g. integers, strings, or booleans).

item()* is the most general type possible, it matches everything, like "Object" in Java. For that reason, it can usually be omitted. But not always, for example the default type in xsl:variable is not item()* but document-node(), to ensure that

<xsl:variable name="rtf"><a>thing</a> </xsl:variable>

continues to behave like XSLT 1.0

Use these to specify parameters, variable types etc.

关于xml - 如何将节点(任何)发送到 xsl :function?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1345003/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com