Monday, 29 December 2014

XSLT-SOME GUIDE

<xsl:apply-template> tag signals the XSLT processor to find the appropriate template to apply, based on the type and context of each selected node.

Following is the example of xslt template :

<xsl:apply-template
   select = Expression
   mode = QName
</xsl:apply-template>
 
 
 
select--> used to process nodes selected by an XPath expression, instead of processing all children
mode--> Allows an element as specified by its Qualified Names to be processed multiple times, each time producing a different result



Simple Example  1 :

Consider this xml :
 <?xml version="1.0"?><?xml-stylesheet type="text/xsl"?><hello-world><greeter>An XSLT Programmer</greeter><greeter1>An XSLT Programmers</greeter1><greeting>Hello, World!</greeting> </hello-world>

XSLT :

<?xml version="1.0"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:template match="/"><xsl:apply-templates select="hello-world/greeter"/></xsl:template><xsl:template match="hello-world/greeter"><xsl:value-of select="." /></xsl:template></xsl:stylesheet>

OUTPUT :

<?xml version="1.0" encoding="UTF-8"?>An XSLT Programmer

Here apply templates calls : template match which in turns displays the value.




good link:


http://www.informit.com/library/content.aspx?b=STY_XML_21days&seqNum=109



No comments:

Post a Comment