开发者

Xml to Xml - Xslt

开发者 https://www.devze.com 2022-12-13 05:39 出处:网络
I am trying to learn xslt but have no good tutorials where i can find all info together please help me here...

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 expr开发者_运维百科essions "@|node()", "@", "{namespace-uri()}", "name()"

means...help me.....


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消