apply-templates

How do I use xsl:apply-templates on the node that is itself generated with xsl?

岁酱吖の 提交于 2020-01-03 03:03:46
问题 I have an xml like this: <span reference="1">Reference Text 1</span> <term reference="2">Reference Text 2</term> And I need it to become this: <span class="referenceText">Reference Text 1</span> <a href="1">[1]</a> <i>Reference Text 2</i> <a href="2">[2]</a> So, basically, if the element with the reference attribute is a span, we just leave it as is, adding class="referenceText" . If, however it is any other element, then we should also apply templates created for this element. That's why

How to apply two templates to the same set of nodes, specifically all the nodes in a XML

我们两清 提交于 2019-12-25 18:14:57
问题 I trying to create an output XML file from an input XML file. Some of the nodes need to be copied from input to output, some with be omitted, and a few of the nodes will have their text modified in some way. However in addition to this, I need to trim the whitespace from the text of every node. I assume that the best way to do this is to have two templates called on the same set of nodes using a mode or some other attribute, but I cannot figure out how to do this. There are too many nodes to

XSL named parameter 'with-param' using 'apply-templates'

和自甴很熟 提交于 2019-12-18 12:23:13
问题 My questions are at the bottom of this post, if you wish to read them before the full explanation. I'm converting an XML document to a pretty web page using XSL, and am having trouble with correctly passing a variable. I have many xsl:template s defined, and need to pass a specific parameter to just one of them. I was hoping that I would be able to pass a named parameter that would presumably be sent to all of the xsl:template s, but only be used by a single one and ignored by the others.

XSL apply-templates output issues

扶醉桌前 提交于 2019-12-12 03:34:27
问题 Given this XML: <?xml version="1.0" encoding="iso-8859-2" ?> <products> <p> <id> 50 </id> <name> Murphy </name> <price> 33 </price> </p> <p> <id> 40 </id> <name> Eddie </name> <price> 9999 </price> </p> <p> <id> 20 </id> <name> Honey </name> <price> 9999 </price> </p> <p> <id> 30 </id> <name> Koney </name> <price> 11 </price> </p> <p> <id> 10 </id> <name> Margarethe </name> <price> 11 </price> </p> </products> With this XSL: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http:

How do I apply templates to each selected node in a for-each?

二次信任 提交于 2019-12-05 05:01:52
I know I'm missing something here. In the XSLT transformation below, the actual result doesn't match the desired result. Inside the for-each , I want to apply the match="track" template to each selected track element. If I've understood XSLT properly, with the current setup only child nodes of each selected track element are matched against templates, not the track elements themselves. How can I make the track elements go through the template as desired? Do I need to rethink my entire approach? Note: The transformation is executed using PHP. XML declarations have been omitted for brevity. XML

XSL named parameter 'with-param' using 'apply-templates'

梦想的初衷 提交于 2019-11-30 06:36:31
My questions are at the bottom of this post, if you wish to read them before the full explanation. I'm converting an XML document to a pretty web page using XSL, and am having trouble with correctly passing a variable. I have many xsl:template s defined, and need to pass a specific parameter to just one of them. I was hoping that I would be able to pass a named parameter that would presumably be sent to all of the xsl:template s, but only be used by a single one and ignored by the others. However, when trying to test this for myself (and my limited understanding of XSL), I was unable to pass

What are the differences between &#39;call-template&#39; and &#39;apply-templates&#39; in XSL?

与世无争的帅哥 提交于 2019-11-26 11:42:56
I am new in XSLT so I'm little bit confused about the two tags, <xsl:apply-templates name="nodes"> and <xsl:call-template select="nodes"> So can you list out the difference between them? Tomalak <xsl:call-template> is a close equivalent to calling a function in a traditional programming language. You can define functions in XSLT, like this simple one that outputs a string. <xsl:template name="dosomething"> <xsl:text>A function that does something</xsl:text> </xsl:template> This function can be called via <xsl:call-template name="dosomething"> . <xsl:apply-templates> is a little different and

What are the differences between &#39;call-template&#39; and &#39;apply-templates&#39; in XSL?

折月煮酒 提交于 2019-11-26 03:29:49
问题 I am new in XSLT so I\'m little bit confused about the two tags, <xsl:apply-templates name=\"nodes\"> and <xsl:call-template select=\"nodes\"> So can you list out the difference between them? 回答1: <xsl:call-template> is a close equivalent to calling a function in a traditional programming language. You can define functions in XSLT, like this simple one that outputs a string. <xsl:template name="dosomething"> <xsl:text>A function that does something</xsl:text> </xsl:template> This function can