xslt

XSLT Muenchian grouping create key inside group

喜欢而已 提交于 2021-02-05 09:40:46
问题 My goal is to group the nodes first by <RowBreak> , then in each <RowBreak> group, I want to group by <ColumnBreak> . Here is my XML. <?xml version="1.0" encoding="utf-8" ?> <Tree> <Item> <Label>Item 1</Label> </Item> <Item> <Label>Item 2</Label> </Item> <ColumnBreak /> <Item> <Label>Item 3</Label> </Item> <Item> <Label>Item 4</Label> </Item> <Item> <Label>Item 5</Label> </Item> <RowBreak /> <Item> <Label>Item 6</Label> </Item> <Item> <Label>Item 7</Label> </Item> <ColumnBreak /> <Item>

XSLT Muenchian grouping create key inside group

£可爱£侵袭症+ 提交于 2021-02-05 09:39:16
问题 My goal is to group the nodes first by <RowBreak> , then in each <RowBreak> group, I want to group by <ColumnBreak> . Here is my XML. <?xml version="1.0" encoding="utf-8" ?> <Tree> <Item> <Label>Item 1</Label> </Item> <Item> <Label>Item 2</Label> </Item> <ColumnBreak /> <Item> <Label>Item 3</Label> </Item> <Item> <Label>Item 4</Label> </Item> <Item> <Label>Item 5</Label> </Item> <RowBreak /> <Item> <Label>Item 6</Label> </Item> <Item> <Label>Item 7</Label> </Item> <ColumnBreak /> <Item>

XSLT 1.0 how to sum values with commas using sum() - walking in xpath

若如初见. 提交于 2021-02-05 09:13:31
问题 I have an XSLT 1.0 transformation to write and I am not finding online good solutions for my problem. I have the following XML example: <?xml version="1.0" encoding="utf-8"?> <MainDoc> <node1> <node2> <User>jsmith</User> <Amount>1,23</Amount> </node2> <node2> <User>abrown</User> <Amount>4,56</Amount> </node2> </node1> As you can see the sum function would not work due to the comma. What I need is to sum all the Amount values, i.e. 1,23 + 4,56 + etc... I tried various solutions without any

How to convert flat xml data to hierarchical data xml

早过忘川 提交于 2021-02-05 08:31:22
问题 I have to convert a flat xml to hierarchical xml. I have no idea for this task. Below is input for conversion. Input:- <body> <p class="title">Article Title</p> <p class="Authors">abc, pqr and xyz</p> <p class="intro">here is introdution text......</p> <p class="head1">1: Heading level 1</p> <p>some text here</p> <p>some text here</p> <p class="head2">1.1: Heading level 2</p> <p>some text here</p> <p>some text here</p> <p class="head3">1.1.1: Heading level 3</p> <p>some text here</p> <p>some

Comparing two xml files using xslt

隐身守侯 提交于 2021-02-05 07:40:44
问题 I have two XML files : File "a": <?xml version="1.0"?> <catalog> <cd>d</cd> <cd>e</cd> <cd>f</cd> <cd>c</cd> </catalog> File "b": <?xml version="1.0"?> <catalog> <cd>a</cd> <cd>b</cd> <cd>c</cd> </catalog> I want to compare File b against File a and get those records which are only present in file b . i.e. Expected output is : <?xml version="1.0"?> <catalog> <cd>a</cd> <cd>b</cd> </catalog> 回答1: If you can use XSLT 2.0, then this can be done very simply (and efficiently) by using a key .

Is there a way to use mode in an xsl:if test?

不羁岁月 提交于 2021-02-05 05:24:26
问题 I've been learning to use the mode attribute with XSLT and was wondering if there's a way to test for it within a template, such as in an xsl:if statement? I've only seen it used at the xsl:template level and maybe that's the only way. Say I want to add a "../" in front of a path attribute (@href), but only if mode="print": <xsl:template name="object" mode="#all"> <img> <xsl:attribute name="src"> <xsl:if test="mode='print'"><xsl:text>../</xsl:text></xsl:if> <xsl:value-of select="@href"/> <

Converting flat hierarchy to nested hierarchy in XSLT depth

*爱你&永不变心* 提交于 2021-02-04 21:13:48
问题 I have some frustratingly flat XML that looks like this: <groups> <group id="1" depth="1" /> <group id="2" depth="2" /> <group id="3" depth="2" /> <group id="4" depth="3" /> <group id="5" depth="2" /> <group id="6" depth="3" /> </groups> The maximum value of depth appears to be 5 . Which I'd like to turn into XML that looks like this: <groups> <group id="1" depth="1"> <group id="2" depth="2"> </group> <group id="3" depth="2"> <group id="4" depth="3"> </group> </group> <group id="5" depth="2">

Converting flat hierarchy to nested hierarchy in XSLT depth

偶尔善良 提交于 2021-02-04 21:13:06
问题 I have some frustratingly flat XML that looks like this: <groups> <group id="1" depth="1" /> <group id="2" depth="2" /> <group id="3" depth="2" /> <group id="4" depth="3" /> <group id="5" depth="2" /> <group id="6" depth="3" /> </groups> The maximum value of depth appears to be 5 . Which I'd like to turn into XML that looks like this: <groups> <group id="1" depth="1"> <group id="2" depth="2"> </group> <group id="3" depth="2"> <group id="4" depth="3"> </group> </group> <group id="5" depth="2">

How do I convert HTML percent-encoding to Unicode, with XSLT?

吃可爱长大的小学妹 提交于 2021-02-04 14:07:53
问题 There are tons of entries and answers online about this, but they're all going the opposite direction of what I need. From my iTunes XML, I have thousands of percent-encoded entries, in multiple languages, that I'm trying to convert, with an XSLT stylesheet, to Unicode text. Is there any function or process that I'm missing, other than tracking down every single character and doing a replace? Here is a small sample of some examples of the variety that I'm working with, the first line is the

How do I convert HTML percent-encoding to Unicode, with XSLT?

隐身守侯 提交于 2021-02-04 14:06:27
问题 There are tons of entries and answers online about this, but they're all going the opposite direction of what I need. From my iTunes XML, I have thousands of percent-encoded entries, in multiple languages, that I'm trying to convert, with an XSLT stylesheet, to Unicode text. Is there any function or process that I'm missing, other than tracking down every single character and doing a replace? Here is a small sample of some examples of the variety that I'm working with, the first line is the