题
如果我该请求发送给一个页:强>
http://www.server.com/show.xml?color=red&number=two
我可以做这样的事情:
I like the color <xsl:url-param name="color" /> and the number <xsl:url-param name="number" />.
如果您需要澄清的问题,还是让我知道
感谢您的任何答案,
Chrelad
解决方案
没有;在一般情况下,XSL引擎不依赖于网络服务器。
然而,大多数XSL引擎让你在传递一些参数与样式表和文档一起所以你的可以的做,如果你从一个基于Web的系统调用它,是你的地图直接通过您的XSL引擎GET参数。
例如,如果你使用PHP,你可以做这样的事情:
<?php
$params = array(
'color' => $_GET['color'],
'number' => $_GET['number']
);
$xsl = new DOMDocument;
$xsl->load('mystylesheet.xsl');
$xml = new DOMDocument;
$xml->load('mydocument.xml');
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
foreach ($params as $key => $val)
$proc->setParameter('', $key, $val);
echo $proc->transformToXML($xml);
您不得不确保你清理你穿过的任何东西。然后,你可以简单地做:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Remember to pick-up the parameters from the engine -->
<xsl:param name="color" />
<xsl:param name="number" />
<xsl:template match="*">
I like the color <xsl:value-of select="$color" />
and the number <xsl:value-of select="$number" />.
</xsl:template>
</xsl:stylesheet>
不隶属于 StackOverflow