簡體   English   中英

XSLTProcessor :: importStylesheet()中出現多個PHP警告

[英]Multiple PHP Warnings in XSLTProcessor::importStylesheet()

錯誤:

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: 
Undefined variable in /transform.php on line 24

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: 
compilation error: file /protocols.xsl line 18 element template in /transform.php on line 24

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: 
Failed to compile predicate in /transform.php on line 24

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: 
Undefined variable in /transform.php on line 24

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: 
compilation error: file /home6/oneninfi/public_html/craigfreeman/iphone/project1/protocols.xsl line 22 element template in /transform.php on line 24

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: 
Failed to compile predicate in /transform.php on line 24

Warning: XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: 
No stylesheet associated to this object in /transform.php on line 35

PHP:

$xsl = new XSLTProcessor();
    $xsldoc = new DOMDocument();
    $xsldoc->load($_GET['xsl'].'.xsl'); // protocols.xsl
    $xsl->importStyleSheet($xsldoc); // LINE 24

    if(isset($_GET['sectionNumber']))
        $xsl->setParameter('', 'sectionNumber', $_GET['sectionNumber']);
    if(isset($_GET['protocolNumber']))
        $xsl->setParameter('', 'protocolNumber', $_GET['protocolNumber']);
    if(isset($_GET['entryNumber']))
        $xsl->setParameter('', 'entryNumber', $_GET['entryNumber']);

    $xmldoc = new DOMDocument();
    $xmldoc->load($_GET['xml'].'.xml');
    echo $xsl->transformToXML($xmldoc); // LINE 35

XSL:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="protocolNumber"></xsl:param>
    <xsl:param name="sectionNumber"></xsl:param>
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="page/section[@id=$sectionNumber]"> // LINE 18
    <xsl:apply-templates select="protocol[@id=$protocolNumber]"/>
</xsl:template>

<xsl:template match="protocol[@id=$protocolNumber]"> // LINE 22
  <h4>(<xsl:value-of select="$sectionNumber"/>.<xsl:value-of select="@id"/>)&nbsp;<xsl:value-of select="@title"/></h4>
    <!-- Applies templates to all child elements -->
    <ol><xsl:apply-templates/></ol>
</xsl:template>

<xsl:template match="start">
  <span class="start"><xsl:value-of select="@level" /></span>
</xsl:template>

<xsl:template match="stop">
  <span class="stop"><xsl:value-of select="@level" />&nbsp;STOP</span>
</xsl:template>

<xsl:template match="note">
  <span class="note"><span class="noteType"><xsl:value-of select="@title" /></span>:&nbsp;<xsl:value-of select="." /></span>
</xsl:template>

<xsl:template match="step">
   <li><span class="step"><xsl:value-of select="."/></span></li>
</xsl:template>

</xsl:stylesheet>

XML:

<?xml version="1.0" encoding="UTF-8"?>
<page type="Protocols">
    <section id="3" title="Adult Cardiac Life Support">
        <protocol id="0" title="Cardiac Arrest - General Procedures">
            <start level="All Levels"/>
                <step>Verify patient is pulseless and apneic.</step>
                <step>Initiate or continue CPR.  CPR is to be continued at all times, except during defibrillation and /or interruptions &lt; 10 sec for patient transfer.</step>
                <step>Assure airway patency and begin use of BVM.  Provide initial BLS airway management, including Oropharyngeal or Nasopharyngeal Airway.</step>
                <step>Apply AED or SAED if available.  If AED already in place, wait until current shock sequence completion to switch to another AED or manual monitor – may use previously applied patches if compatible with new unit.</step>
                <step>Follow prompts provided by AED/SAED device.</step>
                <step>Utilize ALS, or initiate timely transport toward ALS (ALS intercept or hospital if closer).  If ALS not available, no more than 3 shocks should be delivered at the scene.  Defibrillation should not be performed in a moving ambulance.</step>
                <step>Advise receiving hospital ASAP.</step>
            <stop level="EMT"/>
            <start level="EMT-I, CC &amp; P"/>
                <step>If AED/SAED not already applied, quick look using manual monitor and defibrillate PRN after CPR of at least 5 cycles (about 2 minutes).  Apply limb leads and pads in between shock sequences as appropriate.</step>
                <step>Obtain vascular access.</step>
                <step>Secure definitive airway.  If BLS airway is sufficient to maintain chest rise, continue until additional time or resources are available.  If unable to intubate, continue use of BLS airway adjuncts or use alternate airway device.<br/><br/>emove Bag Valve device whenever transferring patient, moving patient in and out of Ambulance, or other times 
when Bag Valve device may dislodge the device.<br/><br/>Reassess airway patency after any movement of patient.</step>
            <stop level="EMT-I" />
            <start level="EMT-CC &amp; P"/>
                <step>Give medications as listed in the following specific arrhythmia / dysrhythmia protocols. 
</step>
                <note title="NOTE">Should IV/IO access not be available, Epinephrine, Atropine, and Lidocaine may be administered via ETT under 
direct, on-line Medical Control.</note>
        </protocol></section></page>

啟用PHP5 XML / XSL

有什么想法嗎? 有什么明顯的東西嗎?

一種可能性是XSL處理器確實在抱怨&nbsp; 沒有被宣布為實體。 嘗試將文檔類型更改為

<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp '&#160;'> ] >

您的樣式表無效XSLT 1.0:模式中不能有變量/參數引用

您可以在XSLT 2.0模式中使用變量/參數引用。

按照@abc的建議,您需要在內容模板中通過該測試。

查看此錯誤:警告:XSLTProcessor :: importStylesheet()[xsltprocessor.importstylesheet]:編譯錯誤:文件/protocols.xsl第24行/transform.php中的第18行元素模板

在第18行上,您具有:

<xsl:template match =“ page / section [@ id = $ sectionNumber ]”> // LINE 18

$ sectionNumber在哪里定義? PHP無法看到它。

我遇到過同樣的問題,如果您使用參數調用XSL,則在XSLTProcessor中似乎是一個問題,請在`

<template match="/"><xsl:parameter name="whatever"/">

然后您可以調用xslt->setParameter ,它在apache日志中給出了錯誤,但似乎可以正常工作!

這里同樣的問題。 我通過將“ xsl:if”節點包含在“ xsl:template”節點中來解決此問題。 在您的情況下,它會給出:

<xsl:template match="page/section"> // LINE 18
    <xsl:if test="@id=$sectionNumber">
        <xsl:apply-templates select="protocol[@id=$protocolNumber]"/>
    </xsl:if>
</xsl:template>

<xsl:template match="protocol"> // LINE 22
    <xsl:if test="@id=$protocolNumber">
        <h4>(<xsl:value-of select="$sectionNumber"/>.<xsl:value-of select="@id"/>)&nbsp;<xsl:value-of select="@title"/></h4>
        <!-- Applies templates to all child elements -->
        <ol><xsl:apply-templates/></ol>
    </xsl:if>
</xsl:template>

在我看來,$ _GET ['xsl']為空。

您的xsl錯誤。 將其加載到XSLTProcessor對象時,它會失敗。 因此,您不能將其應用於xml。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM