tags:

views:

44

answers:

2
+1  Q: 

Xml to Xml - Xslt

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.....

+4  A: 

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. :-)

Ben Blank
Thanks Ben, that really helped...i wasn't aware that these syntax belongs to XPath.this one helped.
Sumit M Asok
That's really common, it seems! But when I was learning XSLT I actually referred to the XPath specs more often than the XSLT ones. Good luck with your learning, I had a lot of fun with it. ;-)
Ben Blank
+1  A: 

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

peter.murray.rust
Thank you, peter.murray.rust
Sumit M Asok