transforming xml using xsl and xslt

12
GUJARAT TECHNOLOGICAL UNIVERSITY Chandkheda, Ahmedabad Affiliated G. H. Patel College of Engineering and Technology, VallabhVidyanagar A Presentation On Transforming XML using XSL and XSLT Under subject of WEB TECHNOLOGY Semester – VI Computer Engineering Submitted by:Hemant Suthar(130110107058) Submitted to:Prof. Rajesh Ahir

Transcript of transforming xml using xsl and xslt

Page 1: transforming xml using xsl and xslt

GUJARAT TECHNOLOGICAL UNIVERSITYChandkheda, Ahmedabad

Affiliated

G. H. Patel College of Engineering and Technology, VallabhVidyanagar

A Presentation

On

Transforming XML using XSL and XSLT

Under subject of WEB TECHNOLOGY

Semester – VI Computer Engineering

Submitted by:Hemant Suthar(130110107058) Submitted to:Prof. Rajesh Ahir

Page 2: transforming xml using xsl and xslt

Content• INTRODUCING XSL• XML TRANSFORMED• XSL ELEMENTS• SIMPLE EXAMPLE

Page 3: transforming xml using xsl and xslt

INTRODUCING XSL• CSS is used as a style sheet language for HTML, XSL is equivalent for

XML.

Page 4: transforming xml using xsl and xslt

CONTINUE..• It covers a family of different languages:1. XSL Transformations (XSLT):a language for transforming XML.2. The XML Path Language (XPath):an expression language used by

XSLT (and many other languages) to access or refer to parts of an XML document.

3. XSL Formatting Objects (XSL-FO):an XML vocabulary for specifying formatting semantics.

Page 5: transforming xml using xsl and xslt

XML TRANSFORMED• XSLT (Extensible Stylesheet Language Transformations) is a language

for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or into XSL Formatting Objects, which may subsequently be converted to other formats, such as PDF, PostScript and PNG.• Several browsers support actual implementation of XSLT; like IE, Firefox,

Netscape.• XSLT allows elements and attributes in the tree to be navigated. Using

Xpath, XSLT defines part of an XML document that match a template. Once found and matched to template the elements can be transformed.

Page 6: transforming xml using xsl and xslt

XSL ELEMENTS• XSL contains many elements that can be used to manipulate, iterate and

select XML for output.1. value-of: allows information to be extracted and added do the resulting

document. select attribute consists of an XPath expression that is similar in addressing parts to an operating system’s file hierarchy with forward slash selecting sub-directories.

2. for-each: used to iterate and select through every XML element; select attribute contains an XPath.

3. sort: information can be sorted for output, simply by adding an <xsl:sort> element inside for-each.

Example:xsl-elements.pdf

Page 7: transforming xml using xsl and xslt

CONTINUE…4. if: <xml:if> allows the specifying of a query to extract information

you may want.for example; <xsl:if test=“year &gt; 2001”>This simply checks whether the year is greater than 2001.5. Choices: when multiple conditions is required, or default, in case

the main condition is not met, <xsl:choose> is used.<c:choose> is used with <xsl:when> and <xsl:otherwise> elements.basic pattern:

Page 8: transforming xml using xsl and xslt

CONTINUE…<xsl:choose>

<xsl:when test “test expression”>output if true

</xsl:when><xsl:otherwise>

output in other cases</xsl:otherwise>

</xsl:choose>Example:xsl-elements.pdf

Page 9: transforming xml using xsl and xslt

CONTINUE…6. Applying Templates: The <xsl:apply-templates> element applies a

template to the current element or to the current element's child nodes.

The <xsl:apply-templates> element applies a template to the current element or to the current element's child nodes.Example:template-xsl.pdf

Page 10: transforming xml using xsl and xslt

SIMPLE EXAMPLE• Create an XSLT style sheet for one student element of the store

library information document and use it to create a display of that element.• final-example.pdf

Page 11: transforming xml using xsl and xslt

REFERENCES:• http://www.w3.org/TR/xslt• http://www.w3.org/Style/XSL/• http://www.w3schools.com/xpath/• http://en.wikipedia.org.wiki/XSLT/• http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile

=cdcatalog_choose• DEVELOPING WEB APPLICATIONS by Ralph Moseley &M.T.Savaliya

Page 12: transforming xml using xsl and xslt

Thank You