xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Victor M. Moreno" <vmor...@germinus.com>
Subject Re: Inserting HTML into the result tree
Date Thu, 02 Aug 2001 08:39:46 GMT
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" <bbu@teamlog.fr>
To: <general@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" <vmoreno@germinus.com>
> To: <general@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


Mime
View raw message