[xquery-talk] Serialize xml to html5 with php.

Michael Seiferle ms at basex.org
Thu Nov 27 08:00:06 PST 2014


Hi France,


I started toying around, here are three more or less pragmatic 
approaches :-)

Are you required to use html(5) serialization? From what I understand 
processing instructions in HTML are serialized differently, '?>' 
serializes to '>':
http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.3.6 
(there may be a better source for this behavior, but this is what I 
found).

In case you are not, you could work around this using xhtml 
serialization:
> declare option output:method "xhtml";
>
> <x>
> <?php print "Hi"  ?>
> <input/>
> </x>

or alternatively add an extra '?':
> declare option output:method "html";
> declare option output:html-version "5.0";
>
> <x>
> <?php haha  ??>
> <input/>
> </x>

or you could make use of PHPs script syntax: 
http://php.net/manual/en/language.basic-syntax.phpmode.php

> <script language="php">
>     echo 'some editors (like FrontPage) don\'t
>          like processing instructions';
> </script>

Best

Michael

On 27 Nov 2014, at 16:33, France Baril wrote:

> Hi,
>
> I was trying to use BaseX to export files that contain some php code, 
> and
> after xml to html5 serialization  <?php ... ?> becomes <?php ...>.
>
> They suggested I contact this list to enquire about any option to 
> export
> the php with the closing '?'?
>
>
> -- 
> France Baril
> Architecte documentaire / Documentation architect
> france.baril at architextus.com
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk


More information about the talk mailing list