You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "Victor M. Moreno" <vm...@germinus.com> on 2001/08/02 09:18:09 UTC

Inserting HTML into the result tree

Hello,
with xalan I transform xml + xsl into a html output.

I am trying to insert: <center>hello</center> in the result tree,
but when I open the output with a browser I get:
&lt;center&gt;hello&lt;/center&gt;

Can anyone help me?

I have built an xsl extension element with xalan, this extension returns the
above html code;
but when using the xsl extension to get the result the html code seems to be
parsed to xml,
or something like that.
Does the xsl extension element have to return a nodeset instead of a String
as I am doing
right now?

Thanks

Victor











---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Inserting HTML into the result tree

Posted by "Victor M. Moreno" <vm...@germinus.com>.
Hello,
yes, that may help me.
But I would like a cleaner solutions.

I explain:
Right now I have a xsl extension function "samplefunction" that return the
string: <center>hello</center>.
If I insert this:
<xsl:value-of disable-output-escaping="yes"
select="publishing2:samplefunction()"/>
 in my xsl file,
everything is fine, and I get the right HTML (thanks Baptiste).

But I would like a cleaner solutions, I would like to insert just:
<publishing2:sampleelement/>
in my xsl file.

As Gary pointed it seems I need to return a NodeSet instead of a String.
But I am new to NodeSet, and I am not finding any sample using NodeSet,
can anyone point me to any NodeSet sample;
or sample of a xsl extension element returning html code.

Thanks very much u all for your help

Regards

Victor






----- Original Message -----
From: "Baptiste Burgaud" <bb...@teamlog.fr>
To: <ge...@xml.apache.org>
Sent: Thursday, August 02, 2001 10:21 AM
Subject: Re: Inserting HTML into the result tree


> Hi Victor,
>
> I'm not sure of what you want to do (and how...) but this may help:
>
> "maBelleBaliseRawHTML" template allow non XHTML output and the "par"
> template shows how to create your own tag without the xsl:element
> instruction (it actually creates an HTML comment as the xsl:comment tag
does
> not seems to work when outputing html)
>
> File helloWorld.java:
> // compilation: javac -classpath
> ".;d:\tmp;d:\tmp\xalan-j_2_0_1\bin\xalan.jar" %f
> // execution: java -classpath
".;d:\tmp;d:\tmp\xalan-j_2_0_1\bin\xalan.jar"
> HelloWorld
>
> import javax.xml.transform.*;
> import javax.xml.transform.stream.*;
>
> import java.io.*;
>
> public class HelloWorld
> {
>  public static void main(String[] args)
>     throws TransformerException, TransformerConfigurationException,
>            FileNotFoundException, IOException
>   {
>    TransformerFactory tFactory = TransformerFactory.newInstance();
>    Transformer transformer = tFactory.newTransformer(new
> StreamSource("helloWorld.xsl"));
>    transformer.transform(new StreamSource("helloWorld.xml"), new
> StreamResult(new FileOutputStream("helloWorld.html")));
>
>    System.out.println("************* The result is in helloWorld.html
> *************");
>   }
> }
>
>
> File helloWorld.xsl:
> <?xml version="1.0" ?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method = "html"/>
> <xsl:comment>this won't output anything!</xsl:comment>
>
>   <xsl:template match="monBeauDocument">
>     <HTML>
>       <HEAD>
>         <TITLE><xsl:value-of select="monBeauTitre"/></TITLE>
>       </HEAD>
>       <BODY>
>         <center>hello</center>
>         <xsl:apply-templates select="maBelleBaliseRawHTML"/>
>         <xsl:apply-templates select="par"/>
>       </BODY>
>     </HTML>
>   </xsl:template>
>
>   <xsl:template match="maBelleBaliseRawHTML">
>     <xsl:value-of disable-output-escaping="yes" select="."/>
>   </xsl:template>
>
>   <xsl:template match="par">
>   <H4>
>     <xsl:text disable-output-escaping="yes"><![CDATA[<!--]]></xsl:text>
>       <xsl:value-of select="@id"/>
>     <xsl:text disable-output-escaping="yes"><![CDATA[-->]]></xsl:text>
>     <xsl:value-of select="."/>
>   </H4>
>   </xsl:template>
>
> </xsl:stylesheet>
>
> File helloWorld.xml:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <monBeauDocument>
>   <monBeauTitre>
>     Hello World
>   </monBeauTitre>
>   <par id="123">
>     un beau paragraphe
>   </par>
>   <maBelleBaliseRawHTML>
>     <![CDATA[
>       <ul>
>         <li>coucou<br>
>         <li>&amp;YOUHOU<BR>
>       </ul>
>     ]]>
>   </maBelleBaliseRawHTML>
> </monBeauDocument>
>
>
>
> ----- Original Message -----
> From: "Victor M. Moreno" <vm...@germinus.com>
> To: <ge...@xml.apache.org>
> Sent: Thursday, August 02, 2001 9:37 AM
> Subject: Re: Inserting HTML into the result tree
>
>
> > Thanks Gary,
> > can you show me any sample in the xalan package?
> >
> > regards
> >
> > Victor
> >
> >
> > > "Victor M. Moreno" wrote:
> > > > Does the xsl extension element have to return a nodeset instead of a
> > String
> > > > as I am doing
> > > > right now?
> > >
> > > Yes.
> > >
> > > ---------------------------------------------------------------------
> > > In case of troubles, e-mail:     webmaster@xml.apache.org
> > > To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: general-help@xml.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > In case of troubles, e-mail:     webmaster@xml.apache.org
> > To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> > For additional commands, e-mail: general-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Inserting HTML into the result tree

Posted by Baptiste Burgaud <bb...@teamlog.fr>.
Hi Victor,

I'm not sure of what you want to do (and how...) but this may help:

"maBelleBaliseRawHTML" template allow non XHTML output and the "par"
template shows how to create your own tag without the xsl:element
instruction (it actually creates an HTML comment as the xsl:comment tag does
not seems to work when outputing html)

File helloWorld.java:
// compilation: javac -classpath
".;d:\tmp;d:\tmp\xalan-j_2_0_1\bin\xalan.jar" %f
// execution: java -classpath ".;d:\tmp;d:\tmp\xalan-j_2_0_1\bin\xalan.jar"
HelloWorld

import javax.xml.transform.*;
import javax.xml.transform.stream.*;

import java.io.*;

public class HelloWorld
{
 public static void main(String[] args)
    throws TransformerException, TransformerConfigurationException,
           FileNotFoundException, IOException
  {
   TransformerFactory tFactory = TransformerFactory.newInstance();
   Transformer transformer = tFactory.newTransformer(new
StreamSource("helloWorld.xsl"));
   transformer.transform(new StreamSource("helloWorld.xml"), new
StreamResult(new FileOutputStream("helloWorld.html")));

   System.out.println("************* The result is in helloWorld.html
*************");
  }
}


File helloWorld.xsl:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method = "html"/>
<xsl:comment>this won't output anything!</xsl:comment>

  <xsl:template match="monBeauDocument">
    <HTML>
      <HEAD>
        <TITLE><xsl:value-of select="monBeauTitre"/></TITLE>
      </HEAD>
      <BODY>
        <center>hello</center>
        <xsl:apply-templates select="maBelleBaliseRawHTML"/>
        <xsl:apply-templates select="par"/>
      </BODY>
    </HTML>
  </xsl:template>

  <xsl:template match="maBelleBaliseRawHTML">
    <xsl:value-of disable-output-escaping="yes" select="."/>
  </xsl:template>

  <xsl:template match="par">
  <H4>
    <xsl:text disable-output-escaping="yes"><![CDATA[<!--]]></xsl:text>
      <xsl:value-of select="@id"/>
    <xsl:text disable-output-escaping="yes"><![CDATA[-->]]></xsl:text>
    <xsl:value-of select="."/>
  </H4>
  </xsl:template>

</xsl:stylesheet>

File helloWorld.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<monBeauDocument>
  <monBeauTitre>
    Hello World
  </monBeauTitre>
  <par id="123">
    un beau paragraphe
  </par>
  <maBelleBaliseRawHTML>
    <![CDATA[
      <ul>
        <li>coucou<br>
        <li>&amp;YOUHOU<BR>
      </ul>
    ]]>
  </maBelleBaliseRawHTML>
</monBeauDocument>



----- Original Message -----
From: "Victor M. Moreno" <vm...@germinus.com>
To: <ge...@xml.apache.org>
Sent: Thursday, August 02, 2001 9:37 AM
Subject: Re: Inserting HTML into the result tree


> Thanks Gary,
> can you show me any sample in the xalan package?
>
> regards
>
> Victor
>
>
> > "Victor M. Moreno" wrote:
> > > Does the xsl extension element have to return a nodeset instead of a
> String
> > > as I am doing
> > > right now?
> >
> > Yes.
> >
> > ---------------------------------------------------------------------
> > In case of troubles, e-mail:     webmaster@xml.apache.org
> > To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> > For additional commands, e-mail: general-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Inserting HTML into the result tree

Posted by "Victor M. Moreno" <vm...@germinus.com>.
Thanks Gary,
can you show me any sample in the xalan package?

regards

Victor


> "Victor M. Moreno" wrote:
> > Does the xsl extension element have to return a nodeset instead of a
String
> > as I am doing
> > right now?
>
> Yes.
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Inserting HTML into the result tree

Posted by Gary L Peskin <ga...@firstech.com>.
Since this is a Xalan-specific question, I've moved things over to the
xalan-dev list.

Victor, this should work.  Can you include a copy of your extension
code?

Thanks,
Gary
 

"Victor M. Moreno" wrote:
> 
> Hello Gary,
> I have finally manage to return a NodeSet,
> but I get  a node set pointer (org.apache.xpath.NodeSet@5e5a50 ) directly in
> the html output.
> 
> What do I have to do in order to insert that node set in the result tree?
> 
> Thanks
> 
> Victor
> 
> ----- Original Message -----
> From: "Gary L Peskin" <ga...@firstech.com>
> To: <ge...@xml.apache.org>
> Sent: Thursday, August 02, 2001 9:29 AM
> Subject: Re: Inserting HTML into the result tree
> 
> > "Victor M. Moreno" wrote:
> > > Does the xsl extension element have to return a nodeset instead of a
> String
> > > as I am doing
> > > right now?
> >
> > Yes.
> >
> > ---------------------------------------------------------------------
> > In case of troubles, e-mail:     webmaster@xml.apache.org
> > To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> > For additional commands, e-mail: general-help@xml.apache.org
> 
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org

Re: Inserting HTML into the result tree

Posted by Gary L Peskin <ga...@firstech.com>.
Since this is a Xalan-specific question, I've moved things over to the
xalan-dev list.

Victor, this should work.  Can you include a copy of your extension
code?

Thanks,
Gary
 

"Victor M. Moreno" wrote:
> 
> Hello Gary,
> I have finally manage to return a NodeSet,
> but I get  a node set pointer (org.apache.xpath.NodeSet@5e5a50 ) directly in
> the html output.
> 
> What do I have to do in order to insert that node set in the result tree?
> 
> Thanks
> 
> Victor
> 
> ----- Original Message -----
> From: "Gary L Peskin" <ga...@firstech.com>
> To: <ge...@xml.apache.org>
> Sent: Thursday, August 02, 2001 9:29 AM
> Subject: Re: Inserting HTML into the result tree
> 
> > "Victor M. Moreno" wrote:
> > > Does the xsl extension element have to return a nodeset instead of a
> String
> > > as I am doing
> > > right now?
> >
> > Yes.
> >
> > ---------------------------------------------------------------------
> > In case of troubles, e-mail:     webmaster@xml.apache.org
> > To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> > For additional commands, e-mail: general-help@xml.apache.org
> 
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Inserting HTML into the result tree

Posted by "Victor M. Moreno" <vm...@germinus.com>.
Hello Gary,
I have finally manage to return a NodeSet,
but I get  a node set pointer (org.apache.xpath.NodeSet@5e5a50 ) directly in
the html output.

What do I have to do in order to insert that node set in the result tree?

Thanks

Victor



----- Original Message -----
From: "Gary L Peskin" <ga...@firstech.com>
To: <ge...@xml.apache.org>
Sent: Thursday, August 02, 2001 9:29 AM
Subject: Re: Inserting HTML into the result tree


> "Victor M. Moreno" wrote:
> > Does the xsl extension element have to return a nodeset instead of a
String
> > as I am doing
> > right now?
>
> Yes.
>
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


More xsl extensions samples

Posted by "Victor M. Moreno" <vm...@germinus.com>.
Hello,
I wonder if there are available more xsl extension samples.
I have already seen all the samples in the xalan package.
I am interested in a extension generating html code into the result tree.

Thanks

Victor



---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Inserting HTML into the result tree

Posted by Gary L Peskin <ga...@firstech.com>.
"Victor M. Moreno" wrote:
> Does the xsl extension element have to return a nodeset instead of a String
> as I am doing
> right now?

Yes.

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Inserting HTML into the result tree

Posted by burtonator <bu...@relativity.yi.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Victor M. Moreno" <vm...@germinus.com> writes:

> Hello,
> with xalan I transform xml + xsl into a html output.
> 
> I am trying to insert: <center>hello</center> in the result tree,
> but when I open the output with a browser I get:
> &lt;center&gt;hello&lt;/center&gt;


Just do the following:

    <xsl:value-of select="extension:doSomething()" disable-output-escaping="yes"/>

Kevin

- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
        Cell: 408-910-6145 URL: http://relativity.yi.org ICQ: 73488596 

In this business, the only real open industry standard in the computer industry
is Linux, which thankfully remains beyond the clutches of the moguls. Everything
else is hokum designed to lock developers (and by extension, customers) into
proprietary corners of the computing constellation.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE7ab0vAwM6xb2dfE0RAk+bAJ0dgA8IdgtZ2szT+cVRDHw3IFPCLACfdBTt
2fhY0xtOH1cxdgjPzN2EdpU=
=bm79
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org