1

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

2
  • 1
    check out w3schools.com/xsl/default.asp for a great tutorial on XSLT Commented Dec 2, 2009 at 17:31
  • w3schools is the first place where i go around for any web based techs...but it doesn't say much about Xml to Xml writing using Xslt...especially about the keywords previously mentioned... Commented Dec 2, 2009 at 17:36

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Ben, that really helped... i wasn't aware that these syntax belongs to XPath. this one helped.
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. ;-)
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.