RE: [PHP] DOM and XSLTProcessor

2007-04-10 Thread Buesching, Logan J
Thanks everyone,

I was able to get it to work by using CDATA and disable-output-escaping.
I guess I was not doing one or the other when I was testing.  Thanks for
all the help it replace a really... _really_ nasty regex, decode,
output.

-Logan

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 10, 2007 7:57 PM
To: Buesching, Logan J
Cc: Tijnema !; php-general@lists.php.net
Subject: RE: [PHP] DOM and XSLTProcessor

On Mon, April 9, 2007 3:50 am, Buesching, Logan J wrote:
> 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.

Can you special decode the limited subset on output, rather than doing
all of them on output, or hacking into the XML on input?

As I understand it...

The point is that the DATA can't have < and > in it, so if you want
that data to come through, you're going to have to encode/decode
somewhere along the line.

PHP automatically encodes for you for this very reason.

It's still up to you to interpret the data correctly at the output end.

Though I am kinda surprised the CDATA solution didn't do it...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] DOM and XSLTProcessor

2007-04-10 Thread Richard Lynch
On Mon, April 9, 2007 3:50 am, Buesching, Logan J wrote:
> 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.

Can you special decode the limited subset on output, rather than doing
all of them on output, or hacking into the XML on input?

As I understand it...

The point is that the DATA can't have < and > in it, so if you want
that data to come through, you're going to have to encode/decode
somewhere along the line.

PHP automatically encodes for you for this very reason.

It's still up to you to interpret the data correctly at the output end.

Though I am kinda surprised the CDATA solution didn't do it...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DOM and XSLTProcessor

2007-04-09 Thread Tony Marston
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.

  

  

  

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: php-general@lists.php.net
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
> something, when shown to the screen, it shows
> <strong> etc...
>
>
>
> Here is the general outline:
>
>
>
> 
> $doc=new DOMDocument("1.0");
>
> $root=$doc->createElement("root");
>
> $wantedCode=$doc->createTextNode("Something");
>
> $root->appendChild($wantedCode);
>
> $doc->appendChild($root);
>
> $proc=new XSLTProcessor;
>
> $proc->importStylesheet(DOMDocument::load("test.xslt"));
>
> echo $proc->transformToXML($doc);
>
> ?>
>
>
>
> SomeSheet is something like:
>
> 
>
>
>
> 
>
>
>
> The expected output that I would like to get is:
>
> Something
>
> (This would just bold my text, not literally see the  tags).
>
>
>
> The actual output is:
>
> <strong>Something</strong>
>
> (This outputs the  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:
>
>
>
> 
> $doc=new DOMDocument("1.0");
>
> $root=$doc->createElement("root");
>
> //note the change right here
>
> $wantedCode=$doc->createCDATASection("Something");
>
> $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



RE: [PHP] DOM and XSLTProcessor

2007-04-09 Thread Buesching, Logan J
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: php-general@lists.php.net
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
> something, when shown to the screen, it shows
> <strong> etc...
>
>
>
> Here is the general outline:
>
>
>
> 
> $doc=new DOMDocument("1.0");
>
> $root=$doc->createElement("root");
>
> $wantedCode=$doc->createTextNode("Something");
>
> $root->appendChild($wantedCode);
>
> $doc->appendChild($root);
>
> $proc=new XSLTProcessor;
>
> $proc->importStylesheet(DOMDocument::load("test.xslt"));
>
> echo $proc->transformToXML($doc);
>
> ?>
>
>
>
> SomeSheet is something like:
>
> 
>
>
>
> 
>
>
>
> The expected output that I would like to get is:
>
> Something
>
> (This would just bold my text, not literally see the  tags).
>
>
>
> The actual output is:
>
> <strong>Something</strong>
>
> (This outputs the  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:
>
>
>
> 
> $doc=new DOMDocument("1.0");
>
> $root=$doc->createElement("root");
>
> //note the change right here
>
> $wantedCode=$doc->createCDATASection("Something");
>
> $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



Re: [PHP] DOM and XSLTProcessor

2007-04-09 Thread Tijnema !

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
something, when shown to the screen, it shows
 etc...



Here is the general outline:



createElement("root");

$wantedCode=$doc->createTextNode("Something");

$root->appendChild($wantedCode);

$doc->appendChild($root);

$proc=new XSLTProcessor;

$proc->importStylesheet(DOMDocument::load("test.xslt"));

echo $proc->transformToXML($doc);

?>



SomeSheet is something like:



   





The expected output that I would like to get is:

Something

(This would just bold my text, not literally see the  tags).



The actual output is:

Something

(This outputs the  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:



createElement("root");

//note the change right here

$wantedCode=$doc->createCDATASection("Something");

$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