1

I am using the following variable in php to handle a customer id:

$k='160177'

which I pass to my xslt using:

...
$xsl = $proc->importStylesheet($xsl);
$xsl = $proc->setParameter('', 'k', $k);
$newdom = $proc->transformToDoc($inputdom);
print $newdom->saveXML();

I pick up the variable in my XSLT and use it to check a node:

...
<xsl:apply-templates select="td:Globale_Pauschale[contains(td:CreatedBy, $k]">

This works fine BUT now I need to pass multiple customer ids via my php variable:

$k='160177,160176,160184,160178,160179....etc'

And get my XSLT contains statement to check against EACH customer id.

In PHP I would change my $k to an array and iterate through it but XSLT has no concept of an array. How do I get XSLT contains to check against EACH customer id ?

Mayn thanks for any help!!

4

1 回答 1

1

唯一要做的是将包含函数调用的顺序更改为 "td:Globale_Pauschale[contains($k,td:CreatedBy)]". $k='160177,160176,160184,160178,160179'比你可以在变量 k ( )中有一个 id 列表。

但这只有在 id 始终具有相同长度的情况下才可靠。(如果您也有较短的 id,这将不起作用16)。

要使其适用于不同长度的 id,请使用以下选择:

select="td:Globale_Pauschale[contains($k, 
            concat(',', normalize-space(td:CreatedBy), ','))]"

并在变量 k 的前面和末尾加一个逗号。
$k=',160177,160176,160184,160178,160179,16,'

于 2013-05-27T16:50:58.190 回答