Professional Web Applications Themes

xslt, php and CDATA problem - PHP Development

Hi there, Not to sure if this is the right group as I am unsure as to the cause of the problem..Anyhowz let me know if this is OT. I am using the php5 XML dom (libxslt) to transform xml doents into xhtml. I have come into a slight problem though, when trying to use CDATA sections in the xsl file to sep off javascript the resulting XHTML also contains the actual CDATA tag. Also if I don't use a CDATA tag in the Javascript the xslt processor used in php seems to automatically add it in, and I am ...

  1. #1

    Default xslt, php and CDATA problem

    Hi there,

    Not to sure if this is the right group as I am unsure as to the cause of
    the problem..Anyhowz let me know if this is OT.

    I am using the php5 XML dom (libxslt) to transform xml doents into
    xhtml. I have come into a slight problem though, when trying to use
    CDATA sections in the xsl file to sep off javascript the resulting XHTML
    also contains the actual CDATA tag.

    Also if I don't use a CDATA tag in the Javascript the xslt processor used
    in php seems to automatically add it in, and I am back to the problem of
    the the resulting code containing the actual CDATA tag, which inturn
    causes the javascript code to be invalid


    XSL File snippet
    ----------------
    <script language="javascript">
    <![CDATA[
    function confirmDelete()
    {
    if( confirm('Are you sure?')
    {
    doent.msgList.submit();
    }
    }
    ]]>
    </script>


    The resulting XHTML looks exactly the same
    ------------------------------------------
    <script language="javascript">
    <![CDATA[
    function confirmDelete()
    {
    if( confirm('Are you sure?')
    {
    doent.msgList.submit();
    }
    }
    ]]>
    </script>

    resulting in client side errors because of invalid JS.

    I was expecting:
    <script language="javascript">
    function confirmDelete()
    {
    if( confirm('Are you sure?')
    {
    doent.msgList.submit();
    }
    }
    </script>



    Is this how CDATA sections are supposed to work? Everywhere I have looked
    said this is the way to output Javascript, infact I can't NOT use CDATA
    as (mentioned above) the PHP processor auto adds them for script
    elements.

    Does anyone have a clue where I am going wrong here?

    Any help would be apreciated, thanks.

    Flibble Guest

  2. #2

    Default Re: xslt, php and CDATA problem


    I forgot to mention the processor is actually processing as the rest of the
    XSL file containing many templates is working fine.
    Flibble Guest

  3. #3

    Default Re: xslt, php and CDATA problem

    Flibble wrote: 
    Hello,

    it would be great to take a look at the template you
    transform <script>...</script>
    Andrey Guest

Similar Threads

  1. Parsing CDATA
    By Keltaz in forum Macromedia Flash Data Integration
    Replies: 1
    Last Post: June 20th, 12:31 PM
  2. DB Locking on CDATA in MX7
    By MTeator in forum Coldfusion Server Administration
    Replies: 2
    Last Post: October 25th, 02:47 PM
  3. CDATA and XMLout
    By Stefan Schmidt in forum PERL Modules
    Replies: 2
    Last Post: January 2nd, 08:45 PM
  4. Replies: 2
    Last Post: September 15th, 02:53 PM
  5. Nested FOR-EACH in XSLT sheet problem
    By Yuri Vorontsov in forum FileMaker
    Replies: 0
    Last Post: July 24th, 09:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139