2009-11-10 5 views
3

오류 :여러 PHP 경고)

 
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 사용

생각 하시겠습니까? 뭐라 구요?

+0

'$ xsldoc->로드 ($ _ GET [ 'xsl']. '. xsl'); –

+0

어떻게 찾을 수 있습니까 ?? – cfree

+0

문제의 정확한 설명은 내 대답을 확인하십시오. –

답변

1

봐 : 경고 : XSLTProcessor에 :: 이는 importStylesheet() [xsltprocessor.importstylesheet] : 컴파일 오류 : 파일 /protocols.xsl 라인 행에서 24 행

에 /transform.php 18 요소 템플릿 18 당신은 :

< XSL : 템플릿 경기 = "페이지/섹션 [ID @ = $ sectionNumber]"// LINE

(18)는 어디 $ sectionNumber이 정의>? PHP는 그것을 볼 수 없다.

+0

은 PHP $ xsl-> setParameter ('', 'sectionNumber', $ _GET [ 'sectionNumber']];)에서 전달 된 XSL의 sectionNumber 매개 변수를 설정합니다. $ sectionNumber를 호출하여 XSL 문서의 다른 곳에서 액세스 할 수 있습니다. – cfree

+0

어쨌든이 매개 변수가 표시되지 않습니다. 그것이 오류라고하는 이유입니다 : 24 행의 /transform.php에있는 정의되지 않은 변수 –

+0

어떤 이유로 든 스타일 시트를 가져 오지 않았다고 생각합니다. – cfree

0

$ _GET [ 'xsl']이 (가) 비어 있음을 나에게 알립니다.

+0

그렇지 않습니다. 변수를 '프로토콜'로 바꿨을 때.xsl '및'http://www.domain.com/protocols.xsl '같은 오류가 발생했습니다 ... – cfree

0

xsl에 오류가 있습니다. XSLTProcessor 개체에로드하면 실패합니다. 따라서 xml을 적용 할 수 없습니다. 이 오류에

+0

나는 그렇게 생각하지 않습니다. 브라우저에서 xsl 파일을 직접 볼 때 오류가 발생하지 않으며 JavaScript를 사용하여 XML을 변환하는 xsl을 얻을 수 있습니다 (모든 클라이언트에서 작동하지 않습니다. 즉 PHP 시도). – cfree

2

XSL 처리기가 실제로 &nbsp;이 엔티티로 선언되지 않는다고 불평 할 가능성이 있습니다. 저도 같은 문제가 발생했습니다

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

좋은 캐치! 그것은 실제로 이미 있습니다. 나는 여기 게시하기 위해 그것을 잘라 냈습니다. 나는 다음에 그 일을하지 않을 것입니다 ... – cfree

+0

그게 아니라면, 나는 버그를 의심합니다. Oxygen/XML에 xsl verbatim을로드했는데 누락 된 항목 만 문제였습니다. 고 정성 테스트를 통과 한 후 고정. –

+0

물론 나는 XSLTProcessor.importStyleSheet()의 버그를 의미합니다. –

1

에 문서 타입을 변경하려고하면, 매개 변수가있는 XSL 전화

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

다음`에 매개 변수를 정의하면 XSLTProcessor에에서 문제가 될 것 같다 당신 xslt->setParameter를 호출 할 수 있습니다, 그것은 아파치 로그에 오류를 제공하지만, 그것은 작동하는 것!

1

같은 문제가 있습니다. 'xsl : template'노드에 'xsl : if'노드를 묶어서 처리했습니다. 귀하의 경우에는 , 그것은 줘야 할 것 :

<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> 
2

스타일 시트가 유효 XSLT 1.0되지 않습니다 : 당신이

당신은 변수/매개 변수 참조를 사용할 수있는 패턴의 변수/매개 변수 참조를 가질 수 없습니다 XSLT 2.0 패턴.

@abc에 의해 제안 된대로 콘텐츠 템플릿 내에서 테스트를 통과해야합니다.

+0

감사합니다. – cfree

+0

@cfree : 안녕하세요! –

+0

몇 년 전에 개발자가 사용했던 libxml 버전이 match 속성에서 허용 된 변수를 사용했지만 QA가 실패한 새로운 환경을 사용하고있었습니다. 원격으로 그걸 알아 내려고하는 것은 재미있었습니다. – grantwparks