XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old November 21st, 2002, 01:10 PM
MrHyde MrHyde is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Posts: 15 MrHyde User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sablotron, PHP, and PI's

Hello,

I've been having some problems getting the xslt_set_sax_handlers() function to work w/ processing instructions.

My current problem is that the $target argument passed into xslt_set_sax_handlers function contains nothing and the $data arg contains the pi target, in this case the string 'php'.

As you can see this is a problem, has anyone experienced this? What's the work around. I really need to be able to use pi's in my xsl docs.

here's the code:

pitest.cgi:
PHP Code:
#!/usr/bin/php4

<?php
    
// Allocate a new XSLT processor
    
$xh xslt_create();
    
xslt_set_sax_handlers($xh, array('pi'=>'process'));
    
/* Processing Instruction handler */
    
function process($parser$target$data) {
        if(
$target == 'php') {
                   
// eval() some code here
          
}
    }
    
// Process the document, returning the result into the $result variable
    
$result xslt_process($xh"pi.xml""test.xsl"NULL, array(), array());
    if (
$result) {
        print 
$result;
    } else {
        print 
"Sorry, sample.xml could not be transformed by sample.xsl into";
        print 
"  the \$result variable the reason is that " xslt_error($xh) .
        print 
" and the error code is " xslt_errno($xh);
    }
    
xslt_free($xh);
?>


pi.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!--<!DOCTYPE doc SYSTEM "dtd/what_press_also.dtd">-->
<doc segment="" product="">
    <test>TEST NODE</test>
    <title>
        blah
        <?php print "TEST";?>
    </title>

    <topnav>
        <?php?>
    </topnav>

    <leftnav>
        <?php?>
    </leftnav>

    <body>
        <?php?>
    </body>

    <contact>
        <?php?>
    </contact>

    <whatshot>
        <ids>1 18 33</ids>
        <?php?>
    </whatshot>

    <seealso>
        <ids>22 57 90</ids>
        <?php?>
    </seealso>

    <footer>
        <?php?>
    </footer>
</doc>

test.xsl:
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:output method="html" />

    <xsl:template match="/">
        <xsl:apply-templates select="doc/title/processing-instruction()"/>
    </xsl:template>

    <xsl:template match="processing-instruction()">
        <xsl:processing-instruction name="php"><xsl:value-of select="."/></xsl:processing-instruction>
    </xsl:template>
</xsl:stylesheet> 

Last edited by MrHyde : November 21st, 2002 at 01:31 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Sablotron, PHP, and PI's


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway