If there are parts of an XML document where you do not want '<' and '>'
changed in '<' and '>' during the transformation then you need to use
the disable-output-escaping option, as in the following example.
<xsl:if test="/root/footer">
<div class="footer">
<xsl:value-of select="/root/footer" disable-output-escaping="yes" />
</div>
</xsl:if>
You also need to insert such text into the XML document using the
createCDATASection() method otherwise the tags will be converted BEFORE the
XSLT processor gets to look at it.
--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
""Buesching, Logan J"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
This could offer a possible workaround.
Let me first state that I cannot simply do:
echo htmlspecialchars_decode($proc->transformToXML($doc));
If I were to do that, then it would assume that all of these encodings
need to be decoded; which definitely is not the case. I only want to do
this for a few of the encodings, which I will know before the XSL
processing. I guess I can do some processing after it went through the
XSL Processor to decode some of the encodings that I do not want, but
that just seems like it would add a lot of unnecessary overhead if it
can be avoided.
Thanks for the idea though.
-Logan
-----Original Message-----
From: Tijnema ! [mailto:[EMAIL PROTECTED]
Sent: Monday, April 09, 2007 4:40 AM
To: Buesching, Logan J
Cc: [email protected]
Subject: Re: [PHP] DOM and XSLTProcessor
On 4/9/07, Buesching, Logan J <[EMAIL PROTECTED]> wrote:
> Greetings,
>
>
>
> I apologize if this is a little long, but I am trying to put as much
> information as I have done in this first post. I am running PHP 5 and
> attempting to use DOM to create data to show on a webpage and using
> XSLTProcessor with an XSLT sheet to output it into XHTML. Everything
is
> pretty fine an dandy until I wish to print raw text, such as xdebug
and
> var_dump.
>
>
>
> My knowledge of DOM and XSLTProcessor is about a 5/10, such that I
know
> most basics, but not the more advanced things. Whenever I try to add
> data using createTextNode, it is always escaped, such that if I do
> <strong>something</strong>, when shown to the screen, it shows
> <strong> etc...
>
>
>
> Here is the general outline:
>
>
>
> <?php
>
> $doc=new DOMDocument("1.0");
>
> $root=$doc->createElement("root");
>
> $wantedCode=$doc->createTextNode("<strong>Something</strong>");
>
> $root->appendChild($wantedCode);
>
> $doc->appendChild($root);
>
> $proc=new XSLTProcessor;
>
> $proc->importStylesheet(DOMDocument::load("test.xslt"));
>
> echo $proc->transformToXML($doc);
>
> ?>
>
>
>
> SomeSheet is something like:
>
> <xsl:template match="/">
>
> <xsl:value-of select="."/>
>
> </xsl:template>
>
>
>
> The expected output that I would like to get is:
>
> <strong>Something</strong>
>
> (This would just bold my text, not literally see the <strong> tags).
>
>
>
> The actual output is:
>
> <strong>Something</strong>
>
> (This outputs the <strong> tags to the end user, which is what I do
not
> want).
>
>
>
> I checked the manual at:
>
http://us3.php.net/manual/en/function.dom-domdocument-createtextnode.php
> . A user comment suggested to use CDATA nodes, so I attempted to
change
> my code to the following:
>
>
>
> <?php
>
> $doc=new DOMDocument("1.0");
>
> $root=$doc->createElement("root");
>
> //note the change right here
>
> $wantedCode=$doc->createCDATASection("<strong>Something</strong>");
>
> $root->appendChild($wantedCode);
>
> $doc->appendChild($root);
>
> $proc=new XSLTProcessor;
>
> $proc->importStylesheet(DOMDocument::load("test.xslt"));
>
> echo $proc->transformToXML($doc);
>
>
>
> ?>
>
>
>
> But this was of no success; it just had the same output.
>
>
>
> Is there anyone that is able to help me out here?
>
>
>
> Thanks,
>
> Logan
Try using htmlspecialchars_decode before outputting your data:
http://www.php.net/manual/en/function.htmlspecialchars-decode.php
Tijnema
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php