1 回答

TA貢獻1788條經驗 獲得超4個贊
我想到了。
當我最初刪除最后兩個選項和結束標記時,我留在了SELECT
XSL 樣式表中的開始標記中。這導致樣式表失敗,因為它有一個沒有結束標記的開始標記。一旦我SELECT
從 XSL 樣式表中刪除了標記行并對 PHP 進行了以下更改,一切都完美無缺。
這是對 PHP 的更改:
$openTag = '<select name="shipping_options" id="shipping_options">';
$closeTag = '<option value=\'8!!!0.00\'>Please call for freight pricing</option>
<option value=\'9!!!0.00\'>Please call for international pricing</option>
</select>';
....
else {
// save request and response to file
$fw = fopen ( $outputFileName, 'w' );
fwrite ( $fw, $response );
fclose ( $fw );
// Load XML file
$xml = new DOMDocument;
$xml->load($outputFileName);
// Load XSL file
$xsl = new DOMDocument;
$xsl->load('style.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
// Attach the xsl rules
$proc->importStyleSheet($xsl);
echo $openTag;
echo $proc->transformToXML($xml);
if ($to_height > 0 && $to_height <= 2) {
echo $openTag . 'extra text here' . $closeTag;
}
else {
echo $openTag . $closeTag;
}
}
添加回答
舉報