xslt-1.0

How to transform some tags to another using XSLT

牧云@^-^@ 提交于 2019-12-11 04:33:10
问题 I have the following xml: <box> <title>bold text</title> some text </box> and the following xsl: <xsl:template match="box"> <p style="background:red;"> <xsl:apply-templates/> </p> </xsl:template> <xsl:template match="title"> <p style='background:green;'> <xsl:apply-templates/> </p> </xsl:template> And I got following: <p style="background:red;"> </p> <p style="background:green;">bold text</p> some text <p></p> But I want following: <p style="background:red;"> <p style="background:green;">bold

why function is not called in xslt?

血红的双手。 提交于 2019-12-11 04:28:51
问题 I am trying to call function .But it not display out .here is my code https://plnkr.co/edit/TN1BN5Yao5Z63RDcBGlN?p=preview <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name="dosomething"> <xsl:text>A function that does something</xsl:text> </xsl:template> <xsl:call-template name="dosomething"/> </xsl:stylesheet> 回答1: xsl:call-template cannot be at the top level of your stylesheet. It must only be used within a template body, for example: <xsl

Convert date format in xslt from YYYYMMDD to MM/DD/YYYY

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 04:17:48
问题 I am Having date in xml file in format like YYYYMMDD Applying the xslt transformation i want to change the format to MM/DD/YYYY . For example, Incoming format - 20160513 Output format - 05/13/2016 回答1: Given: <date>20160513</date> the following: <xsl:template match="date"> <xsl:copy> <xsl:value-of select="substring(., 5, 2)"/> <xsl:text>/</xsl:text> <xsl:value-of select="substring(., 7, 2)"/> <xsl:text>/</xsl:text> <xsl:value-of select="substring(., 1, 4)"/> </xsl:copy> </xsl:template> will

How to use variable node-set in Xpath “contains()” function

╄→尐↘猪︶ㄣ 提交于 2019-12-11 04:05:18
问题 I want to check if node value contains a string that occurs in an attribute of a node with-in variable made as a node-set. <xsl:variable name="Var"> <root> <tag atr="x3"> some string <tag> <tag atr="x4"> some string <tag> <root> <xsl:variable> xml contains: <name>one x3 two<name> i've tried something like : <xsl:value-of select="contains(name,msxsl:node-set($Var)/root/tag/@atr)"/> but it just output's nothing and move on. 回答1: In XPath 1.0 if a function or operator expects a string and is

what's the relationship between XSL and XSLT

巧了我就是萌 提交于 2019-12-11 04:03:11
问题 I know xsl is description language of style sheets associated with the W3C XML but i don't his relationship with XSLT ? someone can give me an example 回答1: XSL stands for Extensible Stylesheet Language. Historically, the XSL Working Group in W3C produced a draft specification under the name XSL, which eventually split into three parts: XSL Transformation (XSLT): is an XML language for transforming XML documents XSL Formatting Objects (XSL-FO): an XML language for specifying the visual

How to do sum having Group By using XSLT 1.0

大憨熊 提交于 2019-12-11 03:47:15
问题 I want to do summing of population per country-wise having city population. It wasn't working, given the sample code below. Could you pls help me in making it working The Input is <cities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org file:/D:/Oracle/JDev11116/jdeveloper/jdev/MyWork/TelenorFTPIssueApp/XSLTGroupProj/MySchema.xsd" xmlns="http://www.example.org"> <city name="Milano" country="Italia" pop="5"/> <city name="Paris" country="France"

Merge the values of multiple elements and take the average of the attribute field

£可爱£侵袭症+ 提交于 2019-12-11 03:44:38
问题 I need to merge the values of multiple elements and take the average of the attribute field. [INPUT] <xml> <characters> <char a="a1" b="b1" y="y1" z="z1" start="1" weight="100">F</char> <char a="a2" b="b2" y="y2" z="z2" start="0" weight="80">r</char> <char a="a3" b="b3" y="y3" z="z3" start="0" weight="80">o</char> <char a="a4" b="b4" y="y4" z="z4" start="0" weight="100">m</char> <char a="a5" b="b5" y="y5" z="z5"> </char> <char a="a6" b="b6" y="y6" z="z6" start="1" weight="100">a</char> <char

Automating exslt:node-set?

隐身守侯 提交于 2019-12-11 03:39:45
问题 Not sure if this is possible, but trying set up something that doesn't make me have to type exslt:node-set when pulling values from a dynamically created node block. I am storing the entire set of nodes in a variable, and wrapping it in exslt:node-set, but why does it not work when I then try to pull from it. Is this possible? <xsl:variable name="LANG"> <xsl:variable name="tmp"> <xsl:element name="foo"> <xsl:element name="bar">Hello</xsl:element> </xsl:element> </xsl:variable> <xsl:value-of

XPath 1.0: Finding count of nodes before a specified node

馋奶兔 提交于 2019-12-11 03:35:27
问题 I am familiar with using preceding axes in XSLT for finding determining the number of preceding elements given the current context. However, I don't see a way to do the same given a node that I've stored in a variable. For example: <xsl:variable name="matchedBook" select="book[text()='The Hobbit']"/> <xsl:variable name="precedingBookCount" select="count(???)"/> Given the following XML, precedingBookCount should equal 3. <available> <book>Lord of the Rings</book> <book>The Hunger Games</book>

Identity Template confusion

余生长醉 提交于 2019-12-11 03:24:21
问题 I am trying to understand functinality of identity template. <xsl:template match='@* | node()'> <xsl:apply-templates select='@* | node()'/> </xsl:template> The above template if present in start of our XSL document, we call it identity template and its function is to call all the templates i.,e., by matching every thing under @* and node() in match. Then it goes to second line apply- templates where it recursively selects all the templates/nodes. please correct me if i am wrong here. My