Hi Arun,

I havent found any standard XSL to convert to HTML/HDML/WML/CHTML! :-(
Just in case if you find them.... please forward them to me.  Thanks in
advance.

I personally think that a single XSL for sinlge ML should suffice. Though I
am not a very good XSL author, I managed to write XSLs to write forms in
HTML/HDML from single XML file. But, I dont have XSLs which cover the
complete list of tags in HTML/HDML/CHTML

I am attaching a sample xml, to-html.xsl and to-hdml.xsl file with this
email. The to-hdml.xsl is a live example of  bad xsl authoring. Because it
uses the <![CDATA[.................]]> tag. But couldnt help it since I dont
have a HDMLFormatter and HTMLFormatter puts the DOCTYPE declaration at the
top!!  eeeks!!!

Hope the files help you. If you find anything incorrect/wrong(or just dont
like the template) please feel free to change the XSL. But, also give the
changes to me so that I will incorporate them  ;-)

Note:- The XSL can only convert only process the following elements from
HTML.
1. form,
2. input type(only one submit per form. and cannot use cancel/clear input
types)
3. select... / option
4. checkbox
5. anchor

I know, one requires much more ... but one can only write to the Lowest
Common Denominator(LCD) to the various formats, in which the data must be
presented. Find workarounds if possible Or dont support them!!

Cheers,

Adam



----- Original Message -----
From: "Arun.N" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 19, 2001 6:25 PM
Subject: Re: newbie Question abt number of xsls


> Hi,
>             Thankx Adam !!! for your reply.
>       I checked what you said .. sounds good.
> but all the examples i found with the cocoon 1.8.2 .... was using a
separate
> stylesheet.
>
> in the code snippet you have shown here, is the to-chtml.xsl and
to-html.xsl
> enough for all the pages. if i am going to support two MLs HTML and CHTML
> .... is a single generic xsl for each ML sufficient??
>
> If so . building  that generic xsl depends on the XML tags i define in my
> application......  or is there any stylesheets which are freely available
so
> that i will follow the protocol defined for the XML tags decided by the
> provider of the xsl.
> I feel if there are any predefined xsl i would prefer and follow the tags
> defined by that ... because as i am not too good in writing xsls,
following
> the protocol will save lot of my development time.
>
> if there are any links for stylesheets to convert from XML to any ML in a
> generic way, please can you give me some links. It will be very helpful
for
> me
>
> Thankz in advance,
> regards,
> Arun.N
>
>
> ----- Original Message -----
> From: "Adam A R" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, November 19, 2001 11:48 AM
> Subject: Re: newbie Question abt number of xsls
>
>
> > Hi Arun,
> >
> > Yes. It is possible to use one .xsl for each ML
> >
> > If you are using Cocoon 1.8 then use the media="xxx" parameter in the
> > processing instruction to specify the useragent for the xsl.
> >
> > eg.
> >
> > <?cocoon-process type="xslt"?>
> > <?xml-stylesheet href="xsl/to-hdml.xsl" type="text/xsl" media="up"?>
> > <?xml-stylesheet href="xsl/to-chtml.xsl" type="text/xsl" media="imode"?>
> > ...
> > ...
> > ...
> > <?xml-stylesheet href="xsl/to-html.xsl" type="text/xsl"?>  <!--  This is
> the
> > default. -->
> >
> >
> > But for this to work, you should configure User-Agents(Browsers) in the
> > cocoon.properties file.
> >
> > part of my cocoon.properties looks like this.
> >
##########################################################################
> > ##########################################
> > # User Agents (Browsers)                 #
> > ##########################################
> >
> > # NOTE: numbers indicate the search order. This is very important since
> > # some words may be found in more than one browser description. (MSIE is
> > # presented as "Mozilla/4.0 (Compatible; MSIE 4.01; ...")
> > #
> > # for example, the "explorer=MSIE" tag indicates that the XSL stylesheet
> > # associated to the media type "explorer" should be mapped to those
> browsers
> > # that have the string "MSIE" in their "user-Agent" HTTP header.
> >
> > browser.0 = up=UP.Browser/
> > browser.1 = explorer=MSIE
> > browser.2 = pocketexplorer=MSPIE
> > browser.3 = handweb=HandHTTP
> > browser.4 = avantgo=AvantGo
> > browser.5 = imode=DoCoMo
> > browser.6 = opera=Opera
> > browser.7 = lynx=Lynx
> > browser.8 = java=Java
> > browser.9 = wap=Nokia
> > browser.10 = wap=UP
> > browser.11 = wap=Wapalizer
> > browser.12 = mozilla5=Mozilla/5
> > browser.13 = mozilla5=Netscape6/
> > browser.14 = netscape=Mozilla
> >
##########################################################################
> >
> >
> > I dont know much of C2. Though I have installed it... lately I am
running
> > short of time.
> > Someone on the list might be able to explain it for C2.
> >
> > But, as far as I know.... you will have to use Matchers for using each
> > stylesheet depending on the user-agent.
> > Can anybody shed light on how to do this in C2??
> >
> >
> > cheers
> > Adam
> >
> >
> > ----- Original Message -----
> > From: Arun.N
> > To: [EMAIL PROTECTED]
> > Sent: Saturday, November 17, 2001 9:06 PM
> > Subject: newbie Question abt number of xsls
> >
> >
> > Hi,
> >         Is it possible to have only one xsl for each type ML ie one for
> WAP
> > one for and one for HTML generation and etc.
> > And all the xml page should use the same stylesheet. according to the
> > useragent it should pick one of the xsl in all the pages.
> > I have a senario where there are 200 pages in the application. As far as
> my
> > understanding for each page we should write an xsl and one for each type
o
> f
> > ML. Is there any generic approach ? because the application will have
lots
> > of pages if there is one to one.
> > ie, as of now i have to support html wap and chtml ... that becomes 200
> xmls
> > + 600 xsl !!!
> >
> > Please suggest me what to do ??
> > I also welcome someother sort of implementaion also.
> > Thankx in advance,
> > Arun.N
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> > For additional commands, e-mail: <[EMAIL PROTECTED]>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
>
>
<?xml version="1.0" encoding="shift_jis"?>

<!-- *** Put the dynamic content into the page *** -->
<?cocoon-process type="xsp"?>
<?xml-logicsheet href="xsl/mm-login-logic.xsl"?>

<?cocoon-process type="i18n"?>
<?i18n-dictionary href="mm-dictionary.xml"?>
<?i18n-debuglevel level="info"?>

<!-- *** Transform into HTML/HDML depending on the user-agent*** -->
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="xsl/to-hdml.xsl" type="text/xsl" media="up"?>
<?xml-stylesheet href="xsl/to-html.xsl" type="text/xsl"?>

<?output encoding="shift_jis"?>

<xsp:page
    language="java"
    xmlns:xsp="http://www.apache.org/1999/XSP/Core";
    xmlns:i18n="http://www.infozone-group.org/i18n";
    xmlns:mm-login="http://www.ianywhere.com/2001/MM/login";
    xmlns:session="http://www.apache.org/1999/XSP/Session";
    create-session="true"
>

<doc>
    <!-- ********************************************************
    ************              Login Form              ***********
    ********************************************************* -->
    <form method="post" charset="shift_jis">
        <xsp:attribute name="action">/fswebapp/cc/mm/dologin.xml</xsp:attribute>
	<string>
	    <i18n:translate>
		<i18n:text>Please log in</i18n:text>
	    </i18n:translate>
	</string>
        <br />
    
        <!-- *** Enter name *** -->
	<input type="text" name="name">
	    <string>
		<i18n:translate>
		    <i18n:text>Name</i18n:text>
		</i18n:translate>
	    </string>
	</input>
        <br />
    
        <!-- *** Enter password *** -->
	<input type="password" name="password">
	    <string>
		<i18n:translate>
		    <i18n:text>Password</i18n:text>
		</i18n:translate>
	    </string>
	</input>
        <br />
    
        <!-- *** Select representative name *** -->
        <select name="rep">
	    <string>
		<i18n:translate>
		    <i18n:text>Representative</i18n:text>
		</i18n:translate>
	    </string>
	    <mm-login:reps/>
        </select>
        <br />
        
        <!-- *** Turn messaging on or off *** -->
        <input type="checkbox" name="messaging">
	    <string>
		<i18n:translate>
		    <i18n:text>Messaging</i18n:text>
		</i18n:translate>
	    </string>
        </input>
        <br />
        <!-- *** Submit the form *** -->
        <input type="submit" value="Login" i18n:attr="value"/>
    </form>
</doc>

</xsp:page>









<?xml version="1.0" encoding="shift_jis"?>
<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>

<xsl:output encoding="shift_jis"/>

<xsl:template match="/">
    <html>
        <xsl:apply-templates/>
    </html>
</xsl:template>

<!-- *** Do nothing for the title *** -->
<xsl:template match="title"/>

<!-- *** Found an element named input *** -->
<xsl:template match="input">
    <xsl:value-of select="string"/>

    <!-- *** create new element for input and add attributes ***
         *** name, type and value                        *** -->
    <xsl:element name="input">
        <xsl:attribute name="name">
            <xsl:value-of select="@name" />
        </xsl:attribute>
        <xsl:attribute name="type">
            <xsl:value-of select="@type" />
        </xsl:attribute>

        <xsl:variable name="someval"><xsl:value-of select="@value"/>
        </xsl:variable>

        <xsl:choose>
            <xsl:when test="$someval = ''"/>
            <xsl:otherwise>
		<xsl:attribute name="value">
		    <xsl:value-of select="@value" />
		</xsl:attribute>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:element>
</xsl:template>

<xsl:template match="form">
    <xsl:element name="form">
        <xsl:attribute name="method">
            <xsl:value-of select="@method"/>
        </xsl:attribute>
        <xsl:attribute name="action">
            <xsl:value-of select="@action"/>
        </xsl:attribute>
        <xsl:attribute name="enc-type">
            <xsl:value-of select="@enc-type"/>
        </xsl:attribute>
        <xsl:attribute name="charset">
            <xsl:value-of select="@charset"/>
        </xsl:attribute>
        <xsl:apply-templates/>
    </xsl:element>
</xsl:template>

<!-- <xsl:template match="//text()"/>
-->
<xsl:template match="br">
<br />
</xsl:template>

<xsl:template match="select">
    <xsl:value-of select="string"/>
    <xsl:text> : </xsl:text>
    <xsl:element name="select">
        <xsl:attribute name="name">
            <xsl:value-of select="@name"/>
        </xsl:attribute>
        <xsl:apply-templates/>
    </xsl:element>
</xsl:template>

<xsl:template match="string">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="option">
    <xsl:element name="option">
        <xsl:attribute name="value">
            <xsl:value-of select="@value"/>
        </xsl:attribute>
	<xsl:apply-templates/>
    </xsl:element>
</xsl:template>


<xsl:template match="a">
    <a>
        <xsl:attribute name="href">
            <xsl:value-of select="@href"/>
        </xsl:attribute>
        <xsl:apply-templates/>
    </a>
</xsl:template>

</xsl:stylesheet>








<?xml version="1.0" encoding="shift_jis"?>

<xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>

<xsl:template match="/">
    <xsl:processing-instruction name="cocoon-format">
        type="text/x-hdml"
    </xsl:processing-instruction>

<!--*******************************************************
   This <hdml> tag will be removed automatically
******************************************************** -->
<hdml>
    <xsl:text><![CDATA[<hdml version="3.0" ttl="0" public="true">]]></xsl:text>
    <xsl:apply-templates/>
    <xsl:text><![CDATA[</hdml>]]></xsl:text>
</hdml>
</xsl:template>

<xsl:template match="title"/>


<!-- **********************************************************************
************          Input type is of type submit          ***************
*********************************************************************** -->
<xsl:template match="form/input[@type='submit']">
<!--     <action type="accept" label="Edit">
          -->
    <!-- *** recieve the variable destination here *** -->
    <xsl:param name="destination"/>
    <xsl:text>
    <![CDATA[<action type="soft1" task="go" label="]]></xsl:text>
    <xsl:value-of select="@value"/>
    <xsl:text><![CDATA[" dest="]]></xsl:text><xsl:value-of select="$destination"/><xsl:text><![CDATA[" method="post" postdata="]]></xsl:text>
    <xsl:for-each select="parent::form/input[@type!='submit']|parent::form/select">
        <xsl:text><![CDATA[&]]></xsl:text>
        <xsl:value-of select="@name"/>
        <xsl:text><![CDATA[=$]]></xsl:text>
        <xsl:value-of select="@name"/>
    </xsl:for-each>
    <xsl:text><![CDATA[">]]></xsl:text>

</xsl:template>

<!-- ************************************************************************
***********             Input type is other than submit           ***********
************************************************************************* -->
<xsl:template match="form/input[@type!='submit']|form/select">
    <xsl:text><![CDATA[<ce task=gosub dest=#]]></xsl:text>
            <xsl:value-of select="@name"/>
    <xsl:text><![CDATA[ receive=]]></xsl:text>
       <xsl:value-of select="@name"/>
    <xsl:text><![CDATA[;curItem>]]></xsl:text>
       <xsl:value-of select="string"/>

    <xsl:choose>
        <xsl:when test="@type = 'password'">
            <xsl:text><![CDATA[ []]]></xsl:text>    
        </xsl:when>

        <xsl:otherwise>
	    <xsl:text><![CDATA[ [$]]></xsl:text>
		<xsl:value-of select="@name"/>
	    <xsl:text><![CDATA[]]]></xsl:text>
	</xsl:otherwise>
    </xsl:choose>
</xsl:template>


<!-- ************************************************************************
**********      Template for a form as child of current context     *********
************************************************************************* -->
<xsl:template match="form">
    <xsl:text><![CDATA[<choice name=someform ikey=curItem>]]></xsl:text>
        <xsl:apply-templates select="input[@type='submit']">
            <xsl:with-param name="destination" select="@action"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="string"/>
        <xsl:apply-templates select="a|input[@type!='submit']|select|a"/>
    <xsl:text><![CDATA[</choice>]]></xsl:text>


<!-- *** create cards for the individual form elements  *** -->
    <xsl:for-each select="input[@type!='submit' and @type!='checkbox']">
        <xsl:text><![CDATA[
            <entry name=]]></xsl:text>
            <xsl:value-of select="@name"/>

        <xsl:text><![CDATA[ key=]]></xsl:text>
            <xsl:value-of select="@name"/><xsl:value-of select="position()"/>
        <xsl:text><![CDATA[><action type=accept task=return retvals=$]]></xsl:text>
        <xsl:value-of select="@name"/><xsl:value-of select="position()"/>
        <xsl:text><![CDATA[;]]></xsl:text>
            <xsl:value-of select="position() + 1"/>
        <xsl:text><![CDATA[><wrap>]]></xsl:text>
            <xsl:value-of select="current()"/>
        <xsl:text><![CDATA[:</entry>]]></xsl:text>
    </xsl:for-each>

    <xsl:for-each select="select">
        <xsl:text><![CDATA[<choice name=]]></xsl:text>
        <xsl:value-of select="@name"/>
        <xsl:text><![CDATA[ key=]]></xsl:text>
        <xsl:value-of select="@name"/><xsl:value-of select="position()"/>
        <xsl:text><![CDATA[><action type=accept task=return retvals=$]]></xsl:text>
        <xsl:value-of select="@name"/><xsl:value-of select="position()"/>
        <xsl:text><![CDATA[;]]></xsl:text>
            <xsl:value-of select="position() + 1"/>
        <xsl:text><![CDATA[>]]></xsl:text>
        <xsl:apply-templates select="option"/>
        <xsl:text><![CDATA[</choice>]]></xsl:text>
    </xsl:for-each>

    <xsl:for-each select="input[@type='checkbox']">
        <xsl:text><![CDATA[<choice name=]]></xsl:text>
        <xsl:value-of select="@name"/>
        <xsl:text><![CDATA[ key=]]></xsl:text>
        <xsl:value-of select="@name"/><xsl:value-of select="position()"/>
        <xsl:text><![CDATA[><action type=accept task=return retvals=$]]></xsl:text>
        <xsl:value-of select="@name"/><xsl:value-of select="position()"/>
        <xsl:text><![CDATA[;]]></xsl:text>
            <xsl:value-of select="position() + 1"/>
        <xsl:text><![CDATA[><ce value=on>on
                            <ce value=off>off]]></xsl:text>
<!--        <xsl:apply-templates select="option"/> -->
        <xsl:text><![CDATA[</choice>]]></xsl:text>
    </xsl:for-each>

</xsl:template>


<xsl:template match="option">
    <xsl:text><![CDATA[<ce value=]]></xsl:text>
    <xsl:value-of select="@value"/>
    <xsl:text><![CDATA[>]]></xsl:text>
    <xsl:apply-templates select="string"/>
</xsl:template>

<xsl:template match="a">
    <xsl:text><![CDATA[
          <a task=go dest=]]></xsl:text>
          <xsl:value-of select="@href"/>
          <xsl:text><![CDATA[>]]></xsl:text>
        <xsl:apply-templates select="string"/>
    <xsl:text><![CDATA[</a>]]></xsl:text>
</xsl:template>

<xsl:template match="comment()">
  <xsl:comment><xsl:value-of select="."/></xsl:comment>
</xsl:template>

<xsl:template match="string">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="br">
    <xsl:text><![CDATA[<br>]]></xsl:text>
</xsl:template>

</xsl:stylesheet>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to