xslt-1.0

Find nodes with the same couple of attributes with xslt and add a new node

大憨熊 提交于 2020-01-06 04:42:06
问题 I need to analyse the following XML input: <LIST> <PRODUCT TYPE="1" REP="0"> <SUB CAT="1.1" COUNT="2"> <ITEM NAME="OCC" BEGIN="0" ND="49"> </ITEM> <ITEM NAME="OCC" BEGIN="0" END="49"> </ITEM> </SUB> </PRODUCT> <PRODUCT TYPE="1" REP="1"> <SUB CAT="1.1" COUNT="1"> <ITEM NAME="PRC" BEGIN="0" END="49"> </ITEM> </SUB> </PRODUCT> </LIST> and transform it with Xslt to obtain the following result: <LIST> <PRODUCT TYPE="1" REP="0"> <SUB CAT="1.1" COUNT="2"> <MULTIPLE /> <ITEM NAME="OCC" BEGIN="0" END=

How to break XSLT for-each loop?

北城以北 提交于 2020-01-06 04:33:25
问题 I know break is not possible in XSLT for-each loop. But from following example, If I want to show 'something' element exist or not. Then I will go through loop and once I got it I want to break loop. I will make one bool variable say isExist=false; I will go through all nodes one by one. Once I got 'something', I will change its value to isExist=true want to break loop here. Now I want to break loop bcoz I want to show status as true or false. But If I will not use break after step 3, it will

Forcing Empty CDATA Elements

别等时光非礼了梦想. 提交于 2020-01-06 01:52:06
问题 I was questioned if i could transform an xml by using xsl (1.0) but with keeping the CDATA elements even if there is no content in it. As xsl beginner i am a little bit overwhelmed by that question... here is a simple sample. what i have <AMOUNT/> what i want <AMOUNT><![CDATA[]]></AMOUNT> is there a way to force empty cdata segments with no content? Is there a way to do it for all elements in the file? Is there a way to do it just for the ones in the cdata-section-elements ? (have a look at

Alternating colors in GPX-Tracks

混江龙づ霸主 提交于 2020-01-06 01:30:08
问题 This Question refers to:How to summarize, group 4000+ GPX Trackpoints as Tracks named for by each days date? Garmin GPS-Tracks provide the option to define a different color for each track. As a perfection to the result of the referring question, I wonder how to apply alternating colors for each GPS-track. For instance the 1st. track (all trackpoints for that day) are colored 'Magenta' the 2nd. day is colored 'DarkGray' and the 3rd. day again 'Magenta'. Using the node (date) to alternate

Avoid code repetition when using xsl:choose and xsl:when

帅比萌擦擦* 提交于 2020-01-05 15:03:12
问题 Is there a clever way to simplify the following stylesheet in order to avoid repeating a whole when block when only one variable is changing between each of those? Ideally I would like something like this, looping 6 times on $i : <xsl:when test="$depth > $i"> [...] <xsl:value-of select="substring($npath,($nlength - $i*2),1) - 1"/> [...] </xsl:when> I'm using XSLT 1.0. XML Input <?xml version='1.0'?> <?xml-stylesheet type="text/xsl" href="stylesheet.xsl" version="1.0"?> <root> <item>Main_A

Avoid code repetition when using xsl:choose and xsl:when

北城余情 提交于 2020-01-05 15:02:34
问题 Is there a clever way to simplify the following stylesheet in order to avoid repeating a whole when block when only one variable is changing between each of those? Ideally I would like something like this, looping 6 times on $i : <xsl:when test="$depth > $i"> [...] <xsl:value-of select="substring($npath,($nlength - $i*2),1) - 1"/> [...] </xsl:when> I'm using XSLT 1.0. XML Input <?xml version='1.0'?> <?xml-stylesheet type="text/xsl" href="stylesheet.xsl" version="1.0"?> <root> <item>Main_A

Removing a self referencing node in xml using xsl

只愿长相守 提交于 2020-01-05 12:15:38
问题 I'm a XSL newb and have really trouble understanding the syntax. What I'm trying to achieve is to remove a node from the xml and its referenced node. This xml is build by running Heatdirectory, a tool provided with WIX Installer. So everything in the file is created dynamically. The one thing I know about the file, is the name of the file I want to remove the reference to. This is and example XML: <?xml version="1.0" encoding="utf-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

Removing a self referencing node in xml using xsl

我们两清 提交于 2020-01-05 12:15:10
问题 I'm a XSL newb and have really trouble understanding the syntax. What I'm trying to achieve is to remove a node from the xml and its referenced node. This xml is build by running Heatdirectory, a tool provided with WIX Installer. So everything in the file is created dynamically. The one thing I know about the file, is the name of the file I want to remove the reference to. This is and example XML: <?xml version="1.0" encoding="utf-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

Format numbers in XML using XSLT

瘦欲@ 提交于 2020-01-05 12:11:36
问题 I have one number in my input xml file like this 0.20 but I want to change to 0,20(comma instead of dot) in my output xml file through xslt. How can I format this number? I don't want to use any templates for it. 回答1: Use format-number($x, '0.00', 'european') in conjuction with <xsl:decimal-format name="european" decimal-separator="," grouping-separator="."/> 回答2: There are different approaches based on which XSLT version you are using. Assuming you have the value 0.20 in an element as below

XSLT: copy Nodes and modify them

自古美人都是妖i 提交于 2020-01-05 10:30:12
问题 Input: <xsl:variable name="nodelist"> <root> <a size="12" number="11"> <sex>male</sex> Jens </a> <a size="12" number="11"> <sex>male</sex> Hulk </a> <a size="12" number="11"> <sex>male</sex> Steven XXXXXXXXXXX </a> <a size="12" number="11"> <sex>male</sex> Joschua </a> <a size="12" number="11"> <sex>female</sex> Angelina </a> </root> </variable> Desired output: <root> <a size="12" number="11"> <sex>male</sex> Jens </a> <a size="12" number="11"> <sex>male</sex> Hulk </a> <a size="12" number=