Web Design With XML And XSL - Best Essay Writing Service Reviews Reviews | Get Coupon Or Discount 2016
Free Essays All Companies All Writing Services

Web design with XML and XSL

Concerting one XML to another XML takes into account a series of transformations steps which successfully does the job. As XSL is under development, another name XSLT inherits all its features and is recommended by W3C. Step: 1 • Every XML document is a tree, data structure, composed of connected nodes beginning with a top node called the root (XML Bible). It further branches into other trees and ends with leaf nodes. It is considered as nodes in general. • An XSLT processor, responsible for the transformation, models an XML document into a tree that includes seven kinds of nodes: o Root o Elements

o Text o Attributes o Namespaces o Processing information o Comments Step 2: • The XSLT transforms one XML tree, taken as an input to another XML tree, the final output. It is also termed as tree building part, meaning: o The operators are used for selecting nodes from a tree. o Then it reorders the nodes and o Finally outputs the nodes. • The operation part of the transformation is as follows: o It contains template rules for conversion, usually contained in the xsl:template element. For example, to apply to the root node of the input tree: <xsl:template match=”/”> <html> <head></head> <body></body>

</html> </xsl:template> o It first needs fix a pattern specifying the nodes it matches; the match attribute holds the pattern of the rule. o It needs to instantiate a template to hold the output o Instruction regarding selecting parts of the input tree to be included in the output tree is taken care by one or more XSLT elements. ? Matching the root element, to be transformed first to the output document (the value “/” matches the root element). For example: <xsl:template match=”/”> <DOCUMENT> <xsl:apply-templates/> </DOCUMENT> </xsl:template> ? The select attribute is used for replacing text.

For example: <xsl:template match=”Great”> <xsl:apply-templates select=”NAME”/> </xsl:template> ? The value of element is used to compute the value of the node to copy it to the output document. For example: <xsl:template match=”Great”> <xsl:value-of select=”NAME”/> </xsl:template> ? Applying simple template to more than one element. It can be done using wildcard (‘*’). For example: <xsl:template match=”*”> <P> <xsl:value-of select=”. “/> </P> </xsl:template> ? Matching children and descendants with ‘/’ and ‘//’. For example: <xsl:template match=”Great/SYMBOL”> <strong><xsl:value-of select=”. “/></strong>

</xsl:template> <xsl:template match=”Great//NAME”> <i><xsl:value-of select=”. “/></i> </xsl:template> ? Matching with ID and ‘@’ symbol. For example: <xsl:template match=”id(‘e98’)”> <b><xsl:value-of select=”. “/></b> </xsl:template> <xsl:template match=”@People”> <I><xsl:value-of select=”. “/></I> </xsl:template> ? Matching comments. For example: <xsl:template match=”comment()”> <i><xsl:value-of select=”. “/></i> </xsl:template> o Finally it would output the pattern into the template once it matches, the content of the xsl:template is the output element. • Step 3: Another way for conversion

o The preprocessing of the XML file can be avoided by transferring it to the client with the XSLT file which explains the rendering process. It can be done by attaching the XSLT style sheet with the XML document and insert the processing instruction (it must have a type attribute with value ‘text/xml’ and link to the document pointed to by the style sheet) in the prolog after the XML declaration. Look below: <? xml version=”1. 0″? > <? xml-stylesheet type=”text/xml” href=”17-2. xsl”? >

References

XML Bible. See: http://www. cafeconleche. org/books/bible2/chapters/ch17. html.

Sample Essay of EssayTigers.com