XML style processing instruction in HTML ?

View: New views
3 Messages — Rating Filter:   Alert me  

Parent Message unknown XML style processing instruction in HTML ?

by alain.benedetti :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello,

I'm doing simplified MVC in PHP. My views (phtml files) are HTML files generated with saxon from xml.

Example source file :
_____________________________________________________
<?xml version='1.0' encoding="UTF-8"?>
<body>
<?php
  echo "This is PHP code";
?>
</body>


XSL file :
_____________________________________________________
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output        method="html" version="4.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/body">
  <html>
    <head>
      <title>Title</title>
    </head>
    <body>
      <xsl:apply-templates/>
      <xsl:comment>Generated by <xsl:value-of select="system-property('xsl:vendor')"/></xsl:comment>
    </body>
  </html>
</xsl:template>

<xsl:template match="processing-instruction()">
  <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>


Result :
_____________________________________________________
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Title</title>
   </head>
   <body>
      <?php echo "This is PHP code";
>
     
      <!--Generated by SAXON 9.1.0.1 from Saxonica-->
   </body>
</html>


_____________________________________________________

Of course, PHP does not understand that, because it wants "XML-Style" processing instruction.

<?php  /* some php instructions */  ?>

Which is what Saxon generates if you change output to XML.

I though it was a bug... but it is not as W3C HTML 4.0 norm says, at appendix B.3.6
http://www.w3.org/TR/html401/appendix/notes.html#h-B.3.6

Processing instructions are a mechanism to capture platform-specific idioms. A processing instruction begins with <? and ends with >

<?instruction >

Clearly not compatible with "XML style"... another SGML soup nightmare !

So, although the question is not specific to Saxon (same thing goes for Xalan)

Question is : is there an option with Saxon (or XSL generic... but I didn't find that in the norm) to generate "XML-Style" Processing-instructions while ouput have been set to HTML ?

Best regards

Alain BENEDETTI








This message and any attachments (the "message") is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 
Do not print this message unless it is necessary,
consider the environment.

                ---------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le 
"message") sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.
N'imprimez ce message que si necessaire,
pensez a l'environnement.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: XML style processing instruction in HTML ?

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

There's no option in Saxon to do this, but it shouldn't be hard to create a custom serializer if that's what you want to do:
 
1. Create a subclass of HTMLEmitter that overrides the processing-instruction() method
 
2. Create a subclass of SerializerFactory that overrides newHTMLEmitter() to instantiate (1)
 
3. Register your SerializerFactory using Configuration.setSerializerFactory()
 
You could also use your own output method name, in which case you would want your SerializerFactory to override getReceiver(), by creating a different Properties object and calling super.getReceiver().
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@... [mailto:saxon-help-bounces@...] On Behalf Of alain.benedetti@...
Sent: 11 July 2008 07:59
To: saxon-help@...
Subject: [saxon] XML style processing instruction in HTML ?


Hello,

I'm doing simplified MVC in PHP. My views (phtml files) are HTML files generated with saxon from xml.

Example source file :
_____________________________________________________
<?xml version='1.0' encoding="UTF-8"?>
<body>
<?php
  echo "This is PHP code";
?>
</body>


XSL file :
_____________________________________________________
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output        method="html" version="4.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/body">
  <html>
    <head>
      <title>Title</title>
    </head>
    <body>
      <xsl:apply-templates/>
      <xsl:comment>Generated by <xsl:value-of select="system-property('xsl:vendor')"/></xsl:comment>
    </body>
  </html>
</xsl:template>

<xsl:template match="processing-instruction()">
  <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>


Result :
_____________________________________________________
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Title</title>
   </head>
   <body>
      <?php echo "This is PHP code";
>
     
      <!--Generated by SAXON 9.1.0.1 from Saxonica-->
   </body>
</html>


_____________________________________________________

Of course, PHP does not understand that, because it wants "XML-Style" processing instruction.

<?php  /* some php instructions */  ?>

Which is what Saxon generates if you change output to XML.

I though it was a bug... but it is not as W3C HTML 4.0 norm says, at appendix B.3.6
http://www.w3.org/TR/html401/appendix/notes.html#h-B.3.6

Processing instructions are a mechanism to capture platform-specific idioms. A processing instruction begins with <? and ends with >

<?instruction >

Clearly not compatible with "XML style"... another SGML soup nightmare !

So, although the question is not specific to Saxon (same thing goes for Xalan)

Question is : is there an option with Saxon (or XSL generic... but I didn't find that in the norm) to generate "XML-Style" Processing-instructions while ouput have been set to HTML ?

Best regards

Alain BENEDETTI







This message and any attachments (the "message") is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 
Do not print this message unless it is necessary,
consider the environment.

                ---------------------------------------------

Ce message et toutes les pieces jointes (ci-apres le 
"message") sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.
N'imprimez ce message que si necessaire,
pensez a l'environnement.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: XML style processing instruction in HTML ?

by David Carlisle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



You always have the option of just putting the ? at the end of the dtat

replace
<xsl:template match="processing-instruction()">
  <xsl:copy-of select="."/>
</xsl:template>

by
<xsl:template match="processing-instruction()">
  <xsl:processing-instruction name="{name()">
   <xsl:value-of select="."/>
   <xsl:text>?</xsl:text>
   </xsl:processing-instruction>
</xsl:template>

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help