2010年10月30日 星期六

What is XSL-FO? How is it related to XSLT?

XSL-FO is a language for formatting XML data for output to paper, screen display or media such as printers. XSL-FO is based on XML language and recommendation by W3C and now formally named XSL. With XSL-FO, users can deploy some output such as PDF, Microsoft Word document, or other format document from XML document and XML schema. Compare to XSLT (Extensible Stylesheet Language Transformations), the XSLT is a declarative language for transforming XML documents into other XML, HTML and text documents.
XSL-FO composes with XSLFO Documents, Areas, Output, Flow, Page, Block, Lists and Tables.
·         XSL-FO Documents
XSL-FO documents are XML files with output information that are stored with .fo or a .fob file extension such as “Network.fo”, and the documents also save XSL-FO documents with an .xml extension, generally, using the common format with .fo extension.
·         XSL-FO Areas
A number of rectangular areas(boxes) are defined by XSL-FO to display output, all the output including text, images, etc, will be formatted into these boxes and then displayed in screen or printed to a media such as printer.
·         XSL-FO Output
XSL-FO output is nested inside <fo:block> elements, nested inside <fo:flow> elements, and in the <fo:page-sequence>. Figure 1 shows that the text “This is the XSL-FO Output” is nested inside the <fo:block> elements, and the output are also given in this table.

XSL-FO Coding
XSL-FO Output
<fo:page-sequence>
  <fo:flow flow-name="xsl-region-body">
      
<fo:block> This is the XSL-FO Output</fo:block>

  </fo:flow>
</fo:page-sequence>
This is the XSL-FO Output

Figure 1 – XSL-FOOutput
·         XSL-FO Pages
XSL-FO uses “Page Masters” templates to set the layout of pages, and each template must have a unique name, as Figure 2 shows some elements including REGION BODY (<fegion-body margin=”4cm”), REGION BEFORE (<fo:region-before extent="3cm"/>), REGION AFTER (<fo:region-after extent="3cm"/>), REGION START (<fo:region-start extent="3cm"/>) and REGION END (<fo:region-end extent="3cm"/>) map to Figure 3(coding).

    Figure 2 – XSL-FO Page-A

XSL-FO Page
<fo:simple-page-master master-name="right-side" page-width="297mm" page-height="210mm" margin-top="2cm" margin-bottom="2cm" margin-left="1cm" margin-right="2cm">
      <fo:region-body margin="4cm"/>
      <fo:region-before extent="3cm"/>
      <fo:region-after extent="3cm"/>
      <fo:region-start extent="3cm"/>
      <fo:region-end extent="3cm"/>
</fo:simple-page-master>

Figure 3 – XSL-FOPage-B
·         XSL-FO List Block
There are four XSL-FO objects used to create lists including,
ü  fo:list-block (<fo:list-block>) contains the whole list
ü  fo:list-item (<fo:list-item>) contains each item in the list
ü  fo:list-item-label (<fo:list-item-label>) contains the label for the list-item
ü  fo:list-item-body (<fo:list-item-body>) contains the content or body of the list-item

 An XSL-FO List given an example as showed in Figure 4.

XSL-FO List Block
XSL-FO Output
<fo:list-block>
   <fo:list-item>
      <fo:list-item-label>
         <fo:block>*</fo:block>
     </fo:list-item-label>
     <fo:list-item-body>
        <fo:block>Block-List-Demo</fo:block>
     </fo:list-item-body>
   </fo:list-item>
</fo:list-block>
*Block-list-Demo

Figure 4 – XSL-FOList Blocks
·         XSL-FO Tables
The XSL-FO table is very similar with HTML table model. There are nine XSL-FO objects are used to define output tables as below,
ü  fo:table-and-caption
ü  fo:table
ü  fo:table-caption
ü  fo:table-column
ü  fo:table-header
ü  fo:table-footer
ü  fo:table-body
ü  fo:table-row
ü  fo:table-cell
The <fo:table-and-caption> element is uses by XSL-FO to define a table. It contains a main <fo:table> element and an optional <fo:caption> element. Figure 5 give a sample for table definition, the input in the left side, and the output in the right side as below figure.

XSL-FO Tables
XSL-FO Output
<fo:table-and-caption>
<fo:table>
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="20mm"/>
<fo:table-header>
     <fo:table-row>
         <fo:table-cell>
             <fo:block font-weight="bold">iPhone</fo:block>
        </fo:table-cell>
        <fo:table-cell>
            <fo:block font-weight="bold">Price</fo:block>
       </fo:table-cell>
    </fo:table-row>
</fo:table-header>
<fo:table-body>
    <fo:table-row>
         <fo:table-cell>
              <fo:block>Apple</fo:block>
         </fo:table-cell>
         <fo:table-cell>
               <fo:block>HK$4000</fo:block>
        </fo:table-cell>
     </fo:table-row>
</fo:table-body>
</fo:table>

Name
IPAddress
iPhone
HK$4000

Figure 5 - XSL-FOTables
·         XSL-FO and XSLT help each other
XSL-FO and XSLT can help each other, and also can do the same things (such as the output functions). Figure 6 shows that using two methods (XSL-FO and XSLT) in the left table, and the output are same in the right side table.

XSL-FO and XSLT Coding
XSL-FO and XSLT Output
<!-- XSL-FO Coding -->
<fo:block font-size="14pt" font-family="verdana" color="red"
space-before="5mm" space-after="5mm">
  Web Technologies
</fo:block>

<!-- XSLT Coding -->
<xsl:template match="header">
  <fo:block font-size="14pt" font-family="verdana" color="red"
  space-before="5mm" space-after="5mm">
    <xsl:apply-templates/>
  </fo:block>
</xsl:template>
Web Technologies

 Figure 6 - XSL-FO and XSLT

·         XSL-FO Software Tools Suggestion
Altova's StyleVision is one powerful tool and easy to use to design some format output such as PDF, Microsoft Office Word, HTML and RTF document output. Figure 7 to 10 demonstrated the sample steps for design the output result. The ref URL is http://www.altova.com.
   Figure 7 – StyleVision-Design

   Figure 8 – StyleVision-HTML_Output

   Figure 9 – StyleVision-PDF_Output

   Figure 10 – StyleVision-XSL-FO Coding
Conclusion
XSL-FO is an XML language for formatting the XML data for output. XSL-FO is a web standard recommended by W3C and formally named XSL.

2010年9月21日 星期二

Web 3.0 World

The Internet grow is verity fast, the web application are popular use in our daily life. The view of  Web 3.0 in my vision should have the following features and values,

Bandwidth improve

Bandwidth is the important requirement for Internet for now and in the future, an average of 50Kbps are used in Web 1.0 with dial-up modem, and Web 2.0 about 1Mbps. I think the average bandwidth is more than 10Mbps will be provided for data communication for users in Web 3.0.

Client side application = server side application

Global or routable IP address (IPv6) will be used in each devices such as mobile phones, air-condition, television, etc. As the IPv6 IP Address are designed to replace the IPv4 IP address and provide enough global or routable IP address for global network, private network (LAN), and also all the devices used in our daily life. In Web 3.0 environment client side application also act as server side application functions such as share some resource and interactive with other server or client side applications. For example, someone can share photos to everyone from her/his mobile phone as the mobile phone act as server functions and with routable IP address assigned from mobile phone provider such as “One Two Three” or “Smartone”. 

VM Ware will become more popular

Virtual machines will be become more popular when the Web 3.0 is coming. More than one OS(operation system) can be deployed in any machine or terminal, including servers side and client side communication devices, for example, mobile phone can install more than one OS(assume that mobile phone have enough memory and CPU for rapid process data exchange) for multi functions, user can use more than one applications provide from difference OS(VM Ware),

User Friendly GUI design

User friendly for design for web application become more important in Web 3.0 period. It is the successful way for business to improve their competitiveness. Web application is easy to use and control is the key to get more users to use their products.

XML Technology improve

During the Web 2.0 period (from 2004), XML technologies are very popular in Internet and Intranet, lots of organizations using XML for any web application development, for example, the HK Yahoo Weather Broadcasting implemented the XML technologies by created connection with Hong Kong Observatory back end servers. In Web 3.0 period, XML technologies become more popular, lots of organizations including small companies, primary schools, and so on, will use the web technic to develop more and more web base applications for public access or internal information communication.  Web technologies will become easy to implement, new development language such as Java, Java script will apply to wide area.

Remote Control Everywhere and Anytime

In Web 3.0 period, remote control everywhere and anytime is possible, as mentioned as before, global and routable IP address (IPv6) are available for all the devices in the world. People can remote control their devices such as air-condition in their office or on the way home.
Semantic Web Implementation
Semantic Web is a group of technologies and methods to allow machines (Computer or mobile device) to understand the meaning of information on the World Wide Web. In Web 3 period, the semantic web will be implemented by web technologies.

Security Protection will improve

Web application developments are rapid, at the same time, the security protection is more important in Web 3.0 than Web 2.0 and Web 1.0.  Hacking technic and skill also improve at the same time, so the web or web application developer must conduct some solution to protect user information. All the OS in server and client sides will enhance the security protection level such as enable firewall function, IPS function and install smart anti-virus software and tools, etc.