Tutorial :Xml to Xml - Xslt



Question:

I am trying to learn xslt but have no good tutorials where i can find all info together

please help me here...

 <xsl:template match="@*|node()">      <xsl:copy>          <xsl:apply-templates select="@*|node()"/>      </xsl:copy>  </xsl:template>      <xsl:template match="@*">      <xsl:attribute namespace="{namespace-uri()}" name="{name()}"/>    </xsl:template>  

this is some code which i found at stackOverFlow But i dont understand , what "exactly" the expressions "@|node()", "@", "{namespace-uri()}", "name()"

means...help me.....


Solution:1

First, I'd point out that you can find this and more in the XPath specs.

The short version is that an @ prefix indicates an attribute node (as opposed to element and text nodes, usually), * means "any name" more or less (so * matches all elements and @* all attributes), node() matches any element or text node, | is the "join" or "union" operator (so @*|node() matches all element, text, and attribute nodes).

Moving on to the less common stuff, namespace-uri() returns the full URI for the namespace of the "context node" (think "this" in OO terms) and name() returns the name of the current node, with the appropriate namespace prefix (note that the prefix is take from the XSLT file, not the XML file, if they differ).

Finally, {...} is a way to include an XPath expression in an attribute value where they aren't normally allowed. You'll most commonly see them in constructs like <a href="{link/url}">.

I realize that's probably a pretty thick read. Hopefully, it helps, though. :-)


Solution:2

I normally use the Zvon tutorials and references which have very comprehensive examples:

http://www.zvon.org/

and for XSLT:

http://www.zvon.org/xxl/XSLTutorial/Output/index.html


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »