문제
이 요청을 페이지로 보내면 :
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" />.
질문에 대한 설명이 필요하다면 Lemme는 알고 있습니다.
답변에 감사드립니다.
Chrelad
해결책
아니; 일반적으로 XSL 엔진은 웹 서버에 연결되어 있지 않습니다.
그러나 대부분의 XSL 엔진은 스타일 시트 및 문서와 함께 일부 매개 변수를 전달할 수 있습니다. ~할 수 있다 웹 지원 시스템에서 호출하는 경우 get 매개 변수를 XSL 엔진에 직접 매핑합니다.
예를 들어, 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