You are here: Articles > Computers & Technology > xml

 See more articles about "xml "

Tutorial Addendum On XML Technologies - XML Aisle Accent (XPath)



 31 December 18:00   

    



    



    

Using XPath in XSL Templates

    



    

XPath expressions are acclimated in XSL templates anywhere if the consistent data blazon is allowed.

    

For example:

    

 

    

<xsl:template match="LocationPathExpression">

    

<xsl:apply-templates select="LocationPathExpression"/>

    

<xsl:value-of select="StringExpression"/>

    

<xsl:for-each select="LocationPathExpression"/>

    



    



    

Let s analysis my sample XML file, dictionary_xsl.xml:

    

 

    

<?xml version="1.0"?>

    

<?xml-stylesheet type="text/xsl" href="dictionary.xsl"?>

    

<dictionary>

    

<!-- dictionary_xsl.xml

    

Absorb (c) 2002 by Dr. Yang

    

-->

    

<word acronym="true">

    

<name>XML</name>

    

<definition referenece="'s Notes">eXtensible Markup

    

Language.</definition>

    

<update date="2002-12-23"/>

    

</word>

    

<word symbol="true">

    

<name><</name>

    

<definition>Mathematical attribute apery the "less than" analytic

    

operation, like: 1<2.</definition>

    

<definition>Reserved attribute in XML apery the alpha of

    

tags, like: <![CDATA[<p>Hello world!</p>]]>

    

</definition>

    

</word>

    

<word symbol="false" acronym="false">

    

<name>extensible</name>

    

<definition>Capable of getting extended.</definition>

    

</word>

    

</dictionary>

    



    



    

And administer the afterward XSL file:

    

 

    

<?xml version="1.0"?>

    

<xsl:stylesheet version="1.0"

    

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

    

<!-- dictionary.xsl, adaptation 3.0

    

Absorb (c) 2002 by Dr. Yang

    

-->

    

<xsl:template match="/child::*">

    

<pre>

    

d_<xsl:value-of select="name(self::node())"/>

    

<xsl:for-each select="child::word">

    

w__<xsl:value-of select="name(self::node())"/>

    

<xsl:apply-templates select="self::node()"/>

    

</xsl:for-each>

    

</pre>

    

</xsl:template>

    

<xsl:template match="child::word">

    

<xsl:for-each select="attribute::*">

    

a___<xsl:value-of select="name(.)"/>=<xsl:value-of select="."/>

    

</xsl:for-each>

    

<xsl:for-each select="child::*">

    

e___<xsl:value-of select="name(self::node())"/>

    

<xsl:apply-templates select="self::node()"/>

    

</xsl:for-each>

    

</xsl:template>

    

<xsl:template match="child::name | child::definition | child::update">

    

<xsl:for-each select="attribute::*">

    

a____<xsl:value-of select="name(.)"/>=<xsl:value-of select="."/>

    

</xsl:for-each>

    

<xsl:for-each select="child::text()">

    

t____<xsl:value-of select="self::node()"/>

    

</xsl:for-each>

    

</xsl:template>

    

</xsl:stylesheet>

    



    



    

I got the afterward output:

    

 

    

d_dictionary

    

w__word

    

a___acronym=true

    

e___name

    

t____XML

    

e___definition

    

a____referenece= s Notes

    

t____eXtensible Markup

    

Language.

    

e___update

    

a____date=2002-12-23

    

w__word

    

a___symbol=true

    

e___name

    

t____<

    

e___definition

    

t____Mathematical attribute apery the "less than" analytic

    

operation, like: 1<2.

    

e___definition

    

t____Reserved attribute in XML apery the alpha of

    

tags, like:

    

t____<p>Hello world!</p>

    

w__word

    

a___symbol=false

    

a___acronym=false

    

e___name

    

t____extensible

    

e___definition

    

t____Capable of getting extended.

    



    



    

Conclusion:

    



    



        

  • XPath technology is not allotment of XSL. But it is advised to advice XSL.

        



  •     

  • XPath allows us to present sub structures of XML files with academic expressions.

        



  •     



    



    



 


 select, value, definition, symbol, child, template, dictionary, xpath, templates, representing, language, apply, acronym, version, match, namet, definitiont, worda, locationpathexpression, stylesheet, notes, , < xsl, xsl for, xsl value, < definition, xsl template, name <, < word, node <, select name, word <, representing the, definition <, < name, < dictionary, dictionary xsl, template match, select child, select self, template <, name self, match child, < xml, templates select, apply templates, xsl apply, xsl template match, select name self, template match child, name self node, apply templates select, select self node, xsl apply templates, operation like 1<, templates select self, mathematical symbol representing, path language xpath, extensible markup language, < word symbol, xml path language, logical operation like,

Share Tutorial Addendum On XML Technologies - XML Aisle Accent (XPath):
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 - XSD Syntax
Simple XML Elements with Pre defined Data TypesSimple XML Element: An XML aspect that has no adolescent elements and attributes.Simple XML elements can be authentic in XSD wit

Tutorial Addendum On XML Technologies - XSD Syntax
Simple XML Elements with Continued Data TypesSimple XML Element: An XML aspect that has no adolescent elements and attributes.Simple XML elements can be authentic by using the pre de

Tutorial Addendum On XML Technologies - XSD Syntax
Empty XML ElementsEmpty XML Element: A appropriate circuitous XML aspect that hasone aspect or added and no adolescent argument nodes. Abandoned XML elements mustbe aut

Tutorial Addendum On XML Technologies - XSD Validation in Java
Validation with XMLReaderUnfortunately, I couldn t acquisition any XML parsers provided in J2SDK 1.4.1_02 that can validate XML anatomy adjoin XSD rules. So I downloaded one of the alotof

Tutorial Addendum On XML Technologies - XSD Validation in Java
Using SAXParserFactory to Amount ParsersXerces J amalgamation can aswell be loaded by the SAXParserFactory.newInstance()method. Actuality is my SAXValidator.java: p

Tutorial Addendum On XML Technologies - XSL - Formatting Achievement
The achievement Elementoutput: An XSL element, confined as a arrangement statement. It sets arrangement agreement values to the XSL processor to ascendancy the achievement f

Tutorial Addendum On XML Technologies - XSL - Formatting Achievement
2. Using "element" and "attribute" statements: element: An XSL element, confined as an achievement statement. It inserts an XML elementwith the defined name into the output.br

Tutorial Addendum On XML Technologies - XSL - Declaring and Applying Templates
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 appe

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