cancel
Showing results for 
Search instead for 
Did you mean: 

How to publish bulk of HTML pages using single XSL

darsat_8
Champ in-the-making
Champ in-the-making
Hi all…
i have very little knowledge abt xsl and xmlschema
my question is that how to publish bulk of HTML pages using single XSL file when we submit web form at the time content creation..
anyone know guide me how to solve this problem….
thanks in advance…
9 REPLIES 9

kvc
Champ in-the-making
Champ in-the-making
Best recommendation in that case is to use only a simple Web Form and Freemarker instead of XSL.

A simple Web Form would be an XSD for a generic article, an XSD for example that just captures a title, summary, and body element, where the title is a simple textbox, the summary a simple textfield, and the body a WYWISYG rich-text field.  Here's an example:


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:trn="http://www.alfresco.org"
           targetNamespace="http://www.alfresco.org"
           elementFormDefault="qualified">
  <xs:element name="generic_article">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="title" type="xs:normalizedString"/>
        <xs:element name="summary" type="xs:string">

          <!– Make textarea just a plain text container with annotation –>
          <xs:annotation>
            <xs:appinfo>
              <alf:appearance>minimal</alf:appearance>
            </xs:appinfo>
          </xs:annotation>

        </xs:element>

        <xs:element name="body" type="xs:string">

          <!– Make textarea include expanding list of RTF options, with expanding size and table controls –>
          <xs:annotation>
            <xs:appinfo>
              <alf:appearance>custom</alf:appearance>
            </xs:appinfo>
          </xs:annotation>

        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

The annotation values are found in your main web-client-config-wcm.xml file.  The "custom" textarea option, for example, is listed in this config file with the following display options (which you can change or add your own instance of):


           <widget xforms-type="xf:textarea"
                   appearance="custom"
                   javascript-class-name="alfresco.xforms.RichTextEditor">
             <param name="theme_advanced_buttons1">bold,italic,underline,strikethrough,separator,fontselect,fontsizeselect</param>
             <param name="theme_advanced_buttons2">link,unlink,image,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,undo,redo,separator,forecolor,backcolor</param>
             <param name="height">600</param>
             <param name="mode">exact</param>
             <param name="force_p_newlines">true</param>
             <param name="apply_source_formatting">true</param>
             <param name="plugins">table</param>
             <param name="theme_advanced_buttons3">tablecontrols</param>
           </widget>


Now, once you have your XML, your best bet is to just use Freemarker.  With Freemarker, you can take any existing HTML page, add your Freemarker decorator at the beginning of your file, strip out your text content and replace with appropriate Freemarker variable to correspond to your XML element nodes, save with an *.ftl extension, and viola - you can associate it with your Web Form and start generating web pages.   It is the simplest path for taking any web page and templatizing it quickly.

An example of what you'd want to make any HTML (or JSP, etc.) page look like when you save as a *.ftl file:


<#ftl ns_prefixes={"D", "http://www.alfresco.org"}>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:xalan="http://xml.apache.org/xalan"
      xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
      xmlns:trn="http://www.alfresco.org"
      xmlns:alf="http://www.alfresco.org">
  <head>
    <title>${generic_article.title}</title>


Hope that helps.  The neat thing here is that it should be relatively quick to get your existing web pages into a template form, with your content in simple limited XML format, which you can always extend and layer in additional richness to later.

Take a spin.  Let us know how you get on.


Kevin

darsat_8
Champ in-the-making
Champ in-the-making
still i didn't understand how to use these files which you given me…
plz explain in simplify mannner..

vijay_alfresco
Champ in-the-making
Champ in-the-making
Your requirement is not clear to me, please let us know what exactly you need

darsat_8
Champ in-the-making
Champ in-the-making
Hi vijay_alfresco
i want to publish Bulk of HTML pages using single xsl.
when we create content in web form in which i have used XSL Template for publishing HTML pages from xml.
i fill couple of information for generating Laptop pages bt i got all all laptop information in to single HTML page..
Still i didnt got solution how to generate seperate HTML page for every Laptop form..
i tried several ways for solving this issue bt still i didnt get it hw to it??
plz sry for my worst english…
even i tried using freemarker template also..
hope u understand my prblm..
i really appreciate for ur reply..

vijay_alfresco
Champ in-the-making
Champ in-the-making
You can have

1. I think you should change the webform to accept details for one single
    Laptop instead of for multiple Laptops.

2. You can leave the webform as it is and you can change your html (.xsl) to
    have hidden DIV tags for each Laptop and give an option of Next and
    Previous buttons and write Javascript to show/hide each DIV in sequence.

I have given a solution as per your my understanding to your message.
You may post your webform and .xsl for more clarity for me on this.

darsat_8
Champ in-the-making
Champ in-the-making
Hi vijay_alfresco
I really appreciate for your reply…
still i did not got exactly  what you sayed??
bt i ll try to understand…
here i am sending   files which is required for creating a web form..
BunchLaptop.xsd
[<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Laptop.xsl"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr"
           targetNamespace="http://www.alfresco.org/alfresco/pr"
           elementFormDefault="qualified">
  <xs:simpleType name="Processor">
    <xs:restriction base="xs:normalizedString">
      <xs:enumeration value="Pentium4"/>
      <xs:enumeration value="celeron"/>
      <xs:enumeration value="AMDAthlon"/>
      <xs:enumeration value="DualCore"/>
     </xs:restriction>
  </xs:simpleType>
  <xs:element name="press-release">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="CustomerName" type="xs:normalizedString"/>
        <xs:element name="E-mail" type="xs:normalizedString"/>
        <xs:element name="city" type="xs:normalizedString"/>
   <xs:element name="laptopinfo" minOccurs="1" maxOccurs="unbounded">
     <xs:complexType>
       <xs:sequence>
         <xs:element name="CompanyName" type="xs:normalizedString"/>
         <xs:element name="Processor" type="prSmiley Tonguerocessor"/>
         <xs:element name="Ram" type="xs:normalizedString"/>
         <xs:element name="ScreenSize" type="xs:normalizedString"/>
         <xs:element name="HardDisk" type="xs:normalizedString"/>
         <xs:element name="DVDWriter" type="xs:normalizedString"/>
         <xs:element name="ExtraFeatures" type="xs:normalizedString"/>
            </xs:sequence>
     </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
]

BunchLaptop.xsl
[<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlnsSmiley Tonguer="http://www.alfresco.org/alfresco/pr">
<xslSmiley Surprisedutput method="html"  encoding="UTF-8" indent="yes"/>
<xsl:variable name="CustName" select="/prSmiley Tongueress-release/pr:CustomerName"/>
<xsl:variable name="Email" select="/prSmiley Tongueress-release/pr:E-mail"/>
<xsl:variable name="city" select="/prSmiley Tongueress-release/pr:city"/>
<xsl:variable name="CompanyName" select="/prSmiley Tongueress-release/pr:laptopinfo/pr:CompanyName"/>
<xsl:variable name="Processor" select="/prSmiley Tongueress-release/pr:laptopinfo/prSmiley Tonguerocessor"/>
<xsl:variable name="Ram" select="/prSmiley Tongueress-release/pr:laptopinfo/pr:Ram"/>
<xsl:variable name="ScreenSize" select="/prSmiley Tongueress-release/pr:laptopinfo/prSmiley FrustratedcreenSize"/>
<xsl:variable name="HardDisk" select="/prSmiley Tongueress-release/pr:laptopinfo/pr:HardDisk"/>
<xsl:variable name="DVDWriter" select="/prSmiley Tongueress-release/pr:laptopinfo/prSmiley Very HappyVDWriter"/>
<xsl:variable name="ExtraFeatures" select="/prSmiley Tongueress-release/pr:laptopinfo/pr:ExtraFeatures"/>
<xsl:template match="/prSmiley Tongueress-release">
   <B><xsl:text>Customer Name  :</xsl:text></B>
   <B><xsl:value-of select="$CustName"/></B><br/>
   <B><xsl:text>E-mail  :</xsl:text></B>
   <B><xsl:value-of select="$Email"/></B><br/>
   <B><xsl:text>City  :</xsl:text></B>
   <B><xsl:value-of select="$city"/></B><br/><br/>
<xsl:for-each select="/prSmiley Tongueress-release/pr:laptopinfo" >
<xsl:if test="position()=1"><xsl:value-of select="normalize-space(/prSmiley Tongueress_release/pr:laptopinfo/pr:CompanyName)"/></xsl:if>
      <B><xsl:text>Company Name  :</xsl:text></B>
      <xsl:value-of select="normalize-space(pr:CompanyName)" disable-output-escaping="yes"/><br/>
      <B><xsl:text>Processor  :</xsl:text></B>
      <xsl:value-of select="normalize-space(prSmiley Tonguerocessor)" disable-output-escaping="yes"/><br/>
      <B><xsl:text>Ram  :</xsl:text></B>
      <xsl:value-of select="normalize-space(pr:Ram)" disable-output-escaping="yes"/><br/>
      <B><xsl:text>Screen Size  :</xsl:text></B>
      <xsl:value-of select="normalize-space(prSmiley FrustratedcreenSize)" disable-output-escaping="yes"/><br/>
      <B><xsl:text>HardDisk  :</xsl:text></B>
      <xsl:value-of select="normalize-space(pr:HardDisk)" disable-output-escaping="yes"/><br/>
      <B><xsl:text>DVD Writer(Yes/No)  :</xsl:text></B>
      <xsl:value-of select="normalize-space(prSmiley Very HappyVDWriter)" disable-output-escaping="yes"/><br/>
      <B><xsl:text>Extra Features  :</xsl:text></B>
      <xsl:value-of select="normalize-space(pr:ExtraFeatures)" disable-output-escaping="yes"/><br/><br/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>]
BunchLaptop.xml
[<alfrescoSmiley Tongueress-release xmlns:alfresco="http://www.alfresco.org/alfresco">
<alfresco:CustomerName></alfresco:CustomerName>
<alfresco:E-mail></alfresco:E-mail>
<alfresco:city></alfresco:city>
<alfresco:laptopinfo>
<alfresco:CompanyName></alfresco:CompanyName>
<alfrescoSmiley Tonguerocessor></alfrescoSmiley Tonguerocessor>
<alfresco:Ram></alfresco:Ram>
<alfrescoSmiley FrustratedcreenSize></alfrescoSmiley FrustratedcreenSize>
<alfresco:HardDisk></alfresco:HardDisk>
<alfrescoSmiley Very HappyVDWriter></alfrescoSmiley Very HappyVDWriter>
<alfresco:ExtraFeatures></alfresco:ExtraFeatures>
</alfresco:laptopinfo>
<alfresco:laptopinfo>
<alfresco:CompanyName></alfresco:CompanyName>
<alfrescoSmiley Tonguerocessor></alfrescoSmiley Tonguerocessor>
<alfresco:Ram></alfresco:Ram>
<alfrescoSmiley FrustratedcreenSize></alfrescoSmiley FrustratedcreenSize>
<alfresco:HardDisk></alfresco:HardDisk>
<alfrescoSmiley Very HappyVDWriter></alfrescoSmiley Very HappyVDWriter>
<alfresco:ExtraFeatures></alfresco:ExtraFeatures>
</alfresco:laptopinfo>
<alfresco:laptopinfo>
<alfresco:CompanyName></alfresco:CompanyName>
<alfrescoSmiley Tonguerocessor></alfrescoSmiley Tonguerocessor>
<alfresco:Ram></alfresco:Ram>
<alfrescoSmiley FrustratedcreenSize></alfrescoSmiley FrustratedcreenSize>
<alfresco:HardDisk></alfresco:HardDisk>
<alfrescoSmiley Very HappyVDWriter></alfrescoSmiley Very HappyVDWriter>
<alfresco:ExtraFeatures></alfresco:ExtraFeatures>
</alfresco:laptopinfo>
</alfrescoSmiley Tongueress-release>]

hope you  understand what i did ????actually….
i used this xsd for uploading XML schema and xsl file  for transformation…

vijay_alfresco
Champ in-the-making
Champ in-the-making
yes, I have explained the same situation before.

1. I think you cannot generate multiple HTML files for each section from webform.

My Solution is as follows

2. If you are good at Javascript and DIV tags, you can modify your .xsl as follows


<xsl:for-each select="/pr:press-release/pr:laptopinfo" >

<xsl:variable name="count" select="position()" />
<DIV id=<xsl:value-of select="count"/> style="visibility:hidden">

<xsl:if test="position()=1"><xsl:value-of select="normalize-space(/pr:press_release/pr:laptopinfo/pr:CompanyName)"/></xsl:if>
<B><xsl:text>Company Name :</xsl:text></B>
<xsl:value-of select="normalize-space(pr:CompanyName)" disable-output-escaping="yes"/><br/>
<B><xsl:text>Processor :</xsl:text></B>
<xsl:value-of select="normalize-space(pr:Processor)" disable-output-escaping="yes"/><br/>
<B><xsl:text>Ram :</xsl:text></B>
<xsl:value-of select="normalize-space(pr:Ram)" disable-output-escaping="yes"/><br/>
<B><xsl:text>Screen Size :</xsl:text></B>
<xsl:value-of select="normalize-space(pr:ScreenSize)" disable-output-escaping="yes"/><br/>
<B><xsl:text>HardDisk :</xsl:text></B>
<xsl:value-of select="normalize-space(pr:HardDisk)" disable-output-escaping="yes"/><br/>
<B><xsl:text>DVD Writer(Yes/No) :</xsl:text></B>
<xsl:value-of select="normalize-space(pr:DVDWriter)" disable-output-escaping="yes"/><br/>
<B><xsl:text>Extra Features :</xsl:text></B>
<xsl:value-of select="normalize-space(pr:ExtraFeatures)" disable-output-escaping="yes"/><br/><br/>

</DIV>
</xsl:for-each>
<input type="button" onclick="selectPreviousDiv()" value="Previous" />
<input type="button" onclick="selectNextDiv()" value="Next" />


See the DIV tags above and

Now, you can write Javascript to select the next DIV to display. So, you'll have only one HTML but you are managing using DIV tags.

You need to put positioning of DIV appropriately, remember all DIV should be positioned at the same location but hidden.

Hope you got the picture of workaround, let me know if you are having any problems or understanding with the above solution.

Thanks,
Vijay

darsat_8
Champ in-the-making
Champ in-the-making
Hi vijay…
thanks to you for continuously guide me for solving my solution…
you sayed tht  we used div tag bt i do not have  any idea abt tht hw to use div tag in java script…
plz explain me detail….

and lastly you mention  this input type…
for what purpose you put this tag in xsl…???


<input type="button" onclick="selectPreviousDiv()" value="Previous" />
<input type="button" onclick="selectNextDiv()" value="Next" />

Thanks you….

vijay_alfresco
Champ in-the-making
Champ in-the-making
You can access the DIV in Javascript using the ID of the DIV tag, further you may need to do some research on Javascript and DIV tags from UI team or from Javascript sites.