[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: producing php with xslt

Subject: Re: producing php with xslt
From: "flourish" <msmith@xxxxxxxx>
Date: Wed, 25 Jul 2001 17:05:33 -0400
xsl processing instruction name php
Thanks all for the help.  I got that much working.  But now I'm having
another problem, and I've got a rough feeling that I'm not going to be able
to solve it gracefully.

I want to put a processing instruction in an attribute.  Is there any way to
do this?

Here's the code for the problem at hand, if you'll be so kind as to look at
it.  The model's a little strange, but the idea is that one stylesheet will
turn certain xml tags into php and xml code, and another stylesheet will
turn that xml into html.  Here's some stripped out code from the various
peices.  This is supposed to make a link to an article using a database id.

********* INITIAL XML **************
<php-link>4</php-link>

********* PHP PRODUCING XSLT ****
<xsl:template match="php-article-link">
  <xsl:processing-instruction name="php">
    php_code_to_get_article_data(<xsl:value-of select="text()"/>);
  </xsl:processing-instruction>
  <link>
  <location>
    <xsl:processing-instruction name="php">
      php_code_to_echo_article_url;
    </xsl:processing-instruction>
  </location>
  <name>
    <xsl:processing-instruction name="php">
      php_code_to_echo_article_name;
    </xsl:processing-instruction>
  </name>
 </link>
</xsl:template>

********* XML OUTPUT FROM ABOVE TEMPLATE **********
<?php php_code_to_get_article_data(4); ?>
<link>
  <location><?php php_code_to_echo_article_url; ?></location>
  <name><?php php_code_to_echo_article_name; ?></name>
</link>

******** XSLT TO PROCESS THE ABOVE XML *************
<xsl:template match="link">
  <a>
    <xsl:attribute>
        <xsl:apply-templates select="location"/>
    </xsl:attribute>
  <xsl:apply-templates select="name"/>
 </a>
</xsl:template>

<xsl:template match="processing-instruction()" priority="-1">
  <xsl:processing-instruction name="name()">
    <xsl:value-of select="."/>
  ?</xsl:processing-instruction>
  <!-- The question mark is to deal with the html formating and pi
problem -->
</xsl:template>

********** XML FROM ABOVE *******************
<?php php_code_to_get_article_data(4); ?>
<a href="php_code_to_echo_article_url; ?"><?php php_code_to_echo_name ?></a>

The stand alone php code and the name come out correctly, but the location
gets its gt and lt signs stripped.  Is there some way to change this?

Thanks, Matt


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.