xslt-1.0

how to sum values with commas using sum()

两盒软妹~` 提交于 2020-01-05 08:43:06
问题 I have the following XML document: <nodes> <node> <type>A</type> <val>1,000</val> </node> <node> <type>B</type> <val>2,000</val> </node> <node> <type>A</type> <val>3,000</val> </node> </nodes> My goal is to get a list of unique types and sum all their <val> s. I'm getting the following output: <nodes> <node> <type>A</type> <sum>3</sum> </node> <node> <type>B</type> <sum>2</sum> </node> </nodes> I was expecting a sum (for type A) of 4000, but I'm getting 3 instead. Here's my xslt: <xsl

Matching nodes between current node and next with a certain tag-name

别说谁变了你拦得住时间么 提交于 2020-01-05 02:46:07
问题 I have XML structured in the following way: <content> <sh1>A</sh1> <sh2>A1</sh2> <sh2>A2</sh2> <sh1>B</sh1> <sh2>B1</sh2> <sh2>B2</sh2> <sh2>B3</sh2> <sh1>C</sh1> <sh2>C1</sh2> <sh2>C2</sh2> <sh1>D</sh1> <sh2>D1</sh2> <sh2>D2</sh2> <sh2>D3</sh2> <sh2>D4</sh2> </content> As you can see there are two tag names of concern here: sh1 and sh2 . These represent headers and sub-headers, and I need to organize them as such in the output XML by nesting their contents (you can see example output here).

Convert flat XML table data where elements are concatenated row and column names into nested XML, using XSLT 1.0

喜欢而已 提交于 2020-01-03 17:12:39
问题 I have XML output representing a table of data being output like this: <results> <Row1.Name>Henry</Row1.Name> <Row1.Id>P162</Row1.Id> <Row1.Age>23</Row1.Age> <Row2.Name>John</Row2.Name> <Row2.Id>P137</Row2.Id> <Row2.Age>27</Row2.Age> <Row3.Name>Mary</Row3.Name> <Row3.Id>L493</Row3.Id> <Row3.Age>32</Row3.Age> </results> and I want to convert it to this: <results> <Row> <Name>Henry</Name> <Id>P162<Id> <Age>23</Age> </Row> <Row> <Name>John</Name> <Id>P137<Id> <Age>27</Age> </Row> <Row> <Name

Convert flat XML table data where elements are concatenated row and column names into nested XML, using XSLT 1.0

前提是你 提交于 2020-01-03 17:12:08
问题 I have XML output representing a table of data being output like this: <results> <Row1.Name>Henry</Row1.Name> <Row1.Id>P162</Row1.Id> <Row1.Age>23</Row1.Age> <Row2.Name>John</Row2.Name> <Row2.Id>P137</Row2.Id> <Row2.Age>27</Row2.Age> <Row3.Name>Mary</Row3.Name> <Row3.Id>L493</Row3.Id> <Row3.Age>32</Row3.Age> </results> and I want to convert it to this: <results> <Row> <Name>Henry</Name> <Id>P162<Id> <Age>23</Age> </Row> <Row> <Name>John</Name> <Id>P137<Id> <Age>27</Age> </Row> <Row> <Name

Re-order XML elements in a specific way using XSLT [closed]

狂风中的少年 提交于 2020-01-03 06:59:25
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I have two XSL variables. 1.ProductID <prdid> <id>8143794</id> <id>8143793</id> <id>8142229</id> <id>8143796</id> </prdid> 2.Productxml <root> <product> <estocklevel>0</estocklevel> <id>8142229</id> <isp_brand

XML to XML conversion with XSLT (Add, delete, modify)

我怕爱的太早我们不能终老 提交于 2020-01-03 04:14:19
问题 I'm trying to convert from one XML (XHTML) file to another one with XSLT. I have to add some new elements and attributes, remove some elements and attributes as well as update the value of some existing attributes. So for with the valuable help given in this forum, I'm able to do many tasks as per the answer of my previous question: XML to XML with XSLT- Add, Remove, Modify Elements and Attributes but the problem arises when the elements have the same name and one same attribute. At that

XSL - remove the duplicate node but keep the original

天大地大妈咪最大 提交于 2020-01-03 03:47:22
问题 Need help in removing the duplicate node from the input xml using XSLT This is how my XML looks like, <?xml version="1.0"?> <NodeA NodeAattr="123"> <NodeB NodeBattr="456"></NodeB> <NodeC> <NodeD="ValueD"> <NodeE Name="ValueABC"> <NodeF Value="0"></NodeF > </NodeE > <NodeE Name="ValueABC"> <NodeF Value="0"></NodeF > </NodeE> </NodeD> </NodeC> </NodeA> My final output should look like <NodeA NodeAattr="123"> <NodeB NodeBattr="456"></NodeB> <NodeC> <NodeD="ValueD"> <NodeE Name="ValueABC"> <NodeF

How to read the processing-instructions properties?

霸气de小男生 提交于 2020-01-03 01:47:26
问题 I have processing-instructions in XML. How can I get the id value in processing-instruction when we apply the <xsl:template match="Dest" > <?abc ?abc:Dest id="e47529cb-4d17-461b-8438-e3b6d9ec1a68"??> </xsl:template> 回答1: The solution is: INPUT: <abc> <?abc ?abc:Dest id="e47529cb-4d17-461b-8438-e3b6d9ec1a68"??> </abc> XSLT: <?xml version='1.0' ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="processing-instruction('abc')"> <P-I><xsl:value

Single quote escaping a dynamic value-of string in XSLT 1.0

百般思念 提交于 2020-01-02 05:07:09
问题 I am defining a JavaScript variable from XSLT and am getting an error due to an unescaped string. I understand that I need to replace this to &apos; , but I'm unsure how to do that in XSLT 1.0. XSLT example: var currentComment = '<xsl:value-of select="root/Reviews/Review/Comment" />'; Rendered javascript with unescaped single quote: var currentComment = 'Let's test a string.', // Causing an error ------^ 回答1: As Ian Roberts pointed out in his comment, you need to account for backslashes and

XML to CSV using XSLT

匆匆过客 提交于 2020-01-01 22:30:01
问题 XML IS: <projects> <project> <name ID="A" StartDate='2012-01-01' EndDate='2012-01-30'>Shockwave</name> <language>Ruby</language> <Manager ID="M1">Nathan</Manager> </project> <project> <name ID="B" StartDate='2012-01-01' EndDate='2012-02-30'>Other</name> <language>Erlang</language> <Manager ID="M2">Kristi</Manager> </project> </projects> I want to copy this XML to CSV using XSLT. There are 1000 such projects. How can I get the output Shown below into a csv: A;2012-01-01;2012-01-30;Shockwave