You are here: Articles > Computers & Technology > xml

 See more articles about "xml "

Tutorial Addendum On XML Technologies - XSL - Declaring and Applying Templates



 31 December 18:00   

    



    



    

Since XSL is a accent based on XML, so all XSL statements are accounting as XML elements.

    

In this note, we will apprentice and play with three basal XSL elements:

    



        

  • "stylesheet": Desclaring an XSL appearance sheet.


  •     

  • "template": Declaring an XSL transformation template.


  •     

  • "apply-templates": Requesting to administer transformation templates.


  •     



    



    

With them, we can ascendancy the XSL processor:

    



        

  • To transform a called aspect by replacing it with a accustomed argument string.


  •     

  • To adjure a transformation of a adolescent aspect aural the transformation

        

    of the ancestor element.



  •     



    



    



    

The stylesheet Element

    



    

stylesheet: The basis aspect of an XSL file, confined as the XSL acknowledgment

    

statement. It specifies the XSL adaptation number,

    

and assembly the XSL namespace to a name prefix.

    



    

<xsl:stylesheet version="1.0"

    

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    

XSL_elements

    

</xsl:stylesheet>

    



    



    



    

The arrangement Element

    



    

template: An XSL element, confined as the arrangement acknowledgment statement.

    

It defines the backup agreeable for elements in the XML antecedent files

    

that matches the defined pattern.

    



    

<xsl:template match="pattern">

    

replacement_content

    

</xsl:template>

    



    



    

where "pattern" is a arrangement acclimated to bout aspect names in the antecedent XML file,

    

and "replace_content" is the achievement to be amid in the aforementioned abode area

    

the analogous elements are.

    



    

If an aspect in the antecedent XML book is matched, the entire

    

element will be replaced, starting from "<" of the starting tag to ">" of the ending

    

tag. By this definition, the backup includes the aspect name, all attributes,

    

text content, and all sub-elements.

    



    

Example, we accept the afterward aspect in the antecedent XML file:

    

 

    

<p a="v">

    

Some argument with a <c>child element</c>.

    

</p>

    



    



    

and the afterward arrangement in the XSL file:

    

 

    

<xsl:template match="p">

    

Backup argument for the aspect "p" in the antecedent XML file.

    

</xsl:template>

    



    



    

the achievement will be:

    

 

    

Backup argument for the aspect "p" in the antecedent XML file.

    



    



    

because the tags, attribute, argument content, and adolescent aspect are all replaced by the

    

text defined in the arrangement statement.

    



    

"replacement_content" in the "template" aspect contains a admixture of:

    



        

  • #PCDATA: Argument cord with entities.


  •     

  • Non-XSL elements: Approved XML elements.


  •     

  • XSL elements: XSL elements that aftermath achievement text, or allegorical added

        

    transformation rules.



  •     



    



    

Example:

    

 

    

<xsl:template match="p">

    

Backup argument for the aspect "p" in the antecedent XML file.

    

</xsl:template>

    



    



    

If this arrangement is acclimated on a "p" aspect in the XML antecedent file, that aspect will be

    

replaced absolutely by the argument defined in the template.

    



    

Example:

    

 

    

<xsl:template match="p">

    

Backup argument with <b>one XML element</b> for the aspect "p"

    

in the antecedent XML file.

    

</xsl:template>

    



    



    

This archetype is the aforementioned as the archetype 1, except that we accept a non XSL aspect in

    

the backup text. No big deal. That non XSL aspect will be allotment of the aftereffect

    

file produced by the transformation. However, back XSL book is aswell an XML file,

    

the backup argument haveto chase XML rules. For example, the afterward template

    

statement create agitation for the transformation process:

    

 

    

<xsl:template match="p">

    

Backup argument with <b>one XML element</B> for the aspect "p"

    

in the antecedent XML file.

    

</xsl:template>

    



    



    

Why? The catastrophe tag </B> doesn t bout the starting tag <b>.

    



    



 


 element, template, replacement, source, elements, transformation, match, example, content, pattern, stylesheet, templates, following, element<, starting, output, specified, statement, child, declaring, , xsl template, < xsl, xml file, source xml, replacement text, file <, template match, xsl elements, non xsl, text for, text with, xsl file, xsl element, xsl template match, replacement text with,

Share Tutorial Addendum On XML Technologies - XSL - Declaring and Applying Templates:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Tutorial Addendum On XML Technologies - XSL - Declaring and Applying Templates
The apply templates Elementapply templates: An XSL aspect confined as an activity statement. It requests the XSL processor to administer transformation templates to assertive eleme

Tutorial Addendum On XML Technologies - XSL - Declaring and Applying Templates
Transformation ChainsWhen the XSL processor is transforming an aspect with a template, if the arrangement containsan "apply templates" statement, the XSL processor will authority the transf

Tutorial Addendum On XML Technologies - XSL - Declaring and Applying Templates
Notice that the achievement architecture is abundant bigger now. Why? I accept amid a brace of HTML tags,<pre and </pre at the alpha and the end of the backup agreeable for the root aspect "p". It tells IE to present ag

Tutorial Addendum On XML Technologies - XSL - Accepting Ethics Out Of Antecedent Elements
After abstruse how and if to transform an aspect and its adolescent elements in the XML sourcefile, now we are traveling to attending at how to retrieve ethics out of the altered locations of thesource element.br

Tutorial Addendum On XML Technologies - XSL - Accepting Ethics Out Of Antecedent Elements
Openning dictionary_xsl.xml with Internet Explorer, I got: dictionary word acronym=true symbol= name XML definition adaptable Mar

Tutorial Addendum On XML Technologies - XSL - Accepting Ethics Out Of Antecedent Elements
Openning dictionary_xsl.xml with Internet Explorer, I got: d_dictionary w__worda___acronym=truee___namet____XMLe___definitiont____eXtensible Markup Language.