XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 18 Oct 2005 10:03 AM
Hello,

I have XML that can contain duplicate, consecutive elements with different contents, for example:

<info>
<para>text A </para>
<note>note A </note>
</info>
<info>
<para>text B</para>
<note>note B</note>
<para>text C</para>
</info>

How can I do the following in XSLT 1.0?

merge the contents of the duplicate elements into a single info element, for example:

<info>
<para>text A</para>
<note>note A</note>
<para>text B</para>
<note>note B</note>
<para>text C</para>
</info>

Thanks,

Ann Marie

Postnext
(Deleted User) Subject: merge contents of consecutive duplicate elements
Author: (Deleted User)
Date: 18 Oct 2005 11:41 AM
If you do want to generate single element to replace group of elements with the same name (and concatinate content) you can use something like this :

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="Key" match="/xml/*" use="local-name()"/>

<xsl:template match="/">
<xml>
<xsl:for-each select="/xml/*">
<xsl:if test="generate-id()= generate-id(key('Key',local-name())[1])">
<xsl:copy select=".">
<xsl:for-each select="key('Key',local-name())">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:if>
</xsl:for-each>
</xml>
</xsl:template>
</xsl:stylesheet>

But from your example I can see that probably you do want to do different thing : just use single <info> as a root and collect all children of all <info> elements from original XML under this info. If this is tha case you can use following XSLT:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xml>
<info>
<xsl:for-each select="xml/info/*">
<xsl:copy-of select="."/>
</xsl:for-each>
</info>
</xml>
</xsl:template>
</xsl:stylesheet>

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 18 Oct 2005 01:54 PM
thanks for the suggestion, Yuriv.

Yes, I want to generate a single element to replace two consecutive info elements that are children of an overview element and have the same name (and concatinate content.) There will be no more than one pair of these info elements in each overview element. I don't want to generate a single element containing all duplicate elements.

For example, this code finds the info element that is a child of an overview element and whose next following sibling is also an info element.

<xsl:template match="overview/info[following-sibling::*[1][self::info]]" >

At this point, I'm stuck. How do I concatenate both elements?

thanks,

Ann Marie

Postnext
Ivan PedruzziSubject: merge contents of consecutive duplicate elements
Author: Ivan Pedruzzi
Date: 18 Oct 2005 03:53 PM
Hi Ann,

Assuming your input looks like this

<?xml version="1.0"?>
<overview>
<info>
<para>text A</para>
<note>note A</note>
</info>
<info>
<para>text A</para>
<note>note A</note>
<para>text B</para>
<note>note B</note>
<para>text C</para>
</info>
</overview>

applying the following

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
<xsl:apply-templates select="overview"/>
</xsl:template>

<xsl:template match="overview">
<xsl:copy>
<info>
<xsl:apply-templates select="*"/>
</info>
</xsl:copy>
</xsl:template>

<xsl:template match="info">
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="*">
<xsl:variable name="current" select="."/>
<xsl:if test="not(../following-sibling::info[1]/*[. = $current])">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>

</xsl:stylesheet>



results in


<?xml version='1.0' ?>
<overview>
<info>
<para>text A</para>
<note>note A</note>
<para>text B</para>
<note>note B</note>
<para>text C</para>
</info>
</overview>


hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 18 Oct 2005 09:07 PM
The info elements are still not merged. Can you see what the problem is? Note that I needed to add the <xsl:apply-templates select="@*|node()"/> statement in the match / template or I got no output at all.

Thanks,

Ann Marie

Here is the xml:

<?xml version="1.0"?>
<doctitle>
<prodtitle>prodtitle</prodtitle>
<title>title</title>
</doctitle>
<subtitle>subtitle</subtitle>
<copyright id="_1">
<para>paragraph</para>
</copyright>
<preface>
<purpose>
<info>
<para>paragraph</para>
</info>
</purpose>
<audience>
<info>
<para>paragraph</para>
</info>
</audience>
<organization>
<info>
<para>paragraph</para>
</info>
</organization>
<relateddocumentation>
<info>
<para>paragraph</para>
</info>
</relateddocumentation>
<boilerplate id="_2">
<concept id="_3">
<title>concept</title>
<overview>
<info>
<para>overview paragraph</para>
</info>
</overview>
<subconcept>
<title>subconcept</title>
<overview>
<info>
<para>overview paragraph A</para>
</info>
<info>
<para>overview paragraph B</para>
</info>
</overview>
<info>
<para>test</para>
</info>
</subconcept>
<minitask>
<title>minitask title</title>
<overview>
<info>
<para>minitask overview paragraph</para>
</info>
</overview>
<minitasksteps>
<minitaskstep>
<action>action</action>
</minitaskstep>
</minitasksteps>
</minitask>
</concept>
</boilerplate>
</preface>

<section solution="all" id="_7" htmlfilename="test">
<title>test</title>
</section>
</document>

Here is the stylesheet:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:key name="Key" match="info" use="local-name()"/>

<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:apply-templates select="overview"/>
</xsl:template>

<xsl:template match="overview">
<xsl:copy>
<info>
<xsl:apply-templates select="*"/>
</info>
</xsl:copy>
</xsl:template>

<xsl:template match="info">
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="*">
<xsl:variable name="current" select="."/>
<xsl:if test="not(../following-sibling::info[1]/*[. = $current])">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>

<!-- Default Copy Statement. -->
<xsl:template match="@*|node()" priority="1">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

Here is the output:

<?xml version="1.0" encoding="UTF-8"?><document language="en" product="ICM" documenttype="guide" softwareversion="1.0" dtdversion="2.8(0)">
<doctitle>
<prodtitle>prodtitle</prodtitle>
<title>title</title>
</doctitle>
<subtitle>subtitle</subtitle>
<copyright id="_1">
<para>paragraph</para>
</copyright>
<preface>
<purpose>
<info>
<para>paragraph</para>
</info>
</purpose>
<audience>
<info>
<para>paragraph</para>
</info>
</audience>
<organization>
<info>
<para>paragraph</para>
</info>
</organization>
<relateddocumentation>
<info>
<para>paragraph</para>
</info>
</relateddocumentation>
<boilerplate id="_2">
<concept id="_3">
<title>concept</title>
<overview>
<info>
<para>overview paragraph</para>
</info>
</overview>
<subconcept>
<title>subconcept</title>
<overview>
<info>
<para>overview paragraph A</para>
</info>
<info>
<para>overview paragraph B</para>
</info>
</overview>
<info>
<para>test</para>
</info>
</subconcept>
<minitask>
<title>minitask title</title>
<overview>
<info>
<para>minitask overview paragraph</para>
</info>
</overview>
<minitasksteps>
<minitaskstep>
<action>action</action>
</minitaskstep>
</minitasksteps>
</minitask>
</concept>
</boilerplate>
</preface>

<section solution="all" id="_7" htmlfilename="test">
<title>test</title>
</section>
</document>

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 18 Oct 2005 09:08 PM
The info elements are still not merged. Can you see what the problem is? Note that I needed to add the <xsl:apply-templates select="@*|node()"/> statement in the match / template or I got no output at all.

Thanks,

Ann Marie

Here is the xml:

<?xml version="1.0"?>
<doctitle>
<prodtitle>prodtitle</prodtitle>
<title>title</title>
</doctitle>
<subtitle>subtitle</subtitle>
<copyright id="_1">
<para>paragraph</para>
</copyright>
<preface>
<purpose>
<info>
<para>paragraph</para>
</info>
</purpose>
<audience>
<info>
<para>paragraph</para>
</info>
</audience>
<organization>
<info>
<para>paragraph</para>
</info>
</organization>
<relateddocumentation>
<info>
<para>paragraph</para>
</info>
</relateddocumentation>
<boilerplate id="_2">
<concept id="_3">
<title>concept</title>
<overview>
<info>
<para>overview paragraph</para>
</info>
</overview>
<subconcept>
<title>subconcept</title>
<overview>
<info>
<para>overview paragraph A</para>
</info>
<info>
<para>overview paragraph B</para>
</info>
</overview>
<info>
<para>test</para>
</info>
</subconcept>
<minitask>
<title>minitask title</title>
<overview>
<info>
<para>minitask overview paragraph</para>
</info>
</overview>
<minitasksteps>
<minitaskstep>
<action>action</action>
</minitaskstep>
</minitasksteps>
</minitask>
</concept>
</boilerplate>
</preface>

<section solution="all" id="_7" htmlfilename="test">
<title>test</title>
</section>
</document>

Here is the stylesheet:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:key name="Key" match="info" use="local-name()"/>

<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:apply-templates select="overview"/>
</xsl:template>

<xsl:template match="overview">
<xsl:copy>
<info>
<xsl:apply-templates select="*"/>
</info>
</xsl:copy>
</xsl:template>

<xsl:template match="info">
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="*">
<xsl:variable name="current" select="."/>
<xsl:if test="not(../following-sibling::info[1]/*[. = $current])">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>

<!-- Default Copy Statement. -->
<xsl:template match="@*|node()" priority="1">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

Here is the output:

<?xml version="1.0" encoding="UTF-8"?><document language="en" product="ICM" documenttype="guide" softwareversion="1.0" dtdversion="2.8(0)">
<doctitle>
<prodtitle>prodtitle</prodtitle>
<title>title</title>
</doctitle>
<subtitle>subtitle</subtitle>
<copyright id="_1">
<para>paragraph</para>
</copyright>
<preface>
<purpose>
<info>
<para>paragraph</para>
</info>
</purpose>
<audience>
<info>
<para>paragraph</para>
</info>
</audience>
<organization>
<info>
<para>paragraph</para>
</info>
</organization>
<relateddocumentation>
<info>
<para>paragraph</para>
</info>
</relateddocumentation>
<boilerplate id="_2">
<concept id="_3">
<title>concept</title>
<overview>
<info>
<para>overview paragraph</para>
</info>
</overview>
<subconcept>
<title>subconcept</title>
<overview>
<info>
<para>overview paragraph A</para>
</info>
<info>
<para>overview paragraph B</para>
</info>
</overview>
<info>
<para>test</para>
</info>
</subconcept>
<minitask>
<title>minitask title</title>
<overview>
<info>
<para>minitask overview paragraph</para>
</info>
</overview>
<minitasksteps>
<minitaskstep>
<action>action</action>
</minitaskstep>
</minitasksteps>
</minitask>
</concept>
</boilerplate>
</preface>

<section solution="all" id="_7" htmlfilename="test">
<title>test</title>
</section>
</document>

Postnext
(Deleted User) Subject: merge contents of consecutive duplicate elements
Author: (Deleted User)
Date: 19 Oct 2005 08:22 AM
If your task is to replace all <info> elements located under <overview> element with a single <info> element and concatinate children under this new <info> and you want to do this in cases a) and b) :

a) <overview>
<info/>
<other/>
<info/>
</overview>


and

b)
<overview>
<info/>
<info/>
<other/>
</overview>

then you can use this :

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
<xml>
<xsl:apply-templates select="descendant::overview"/>
</xml>
</xsl:template>

<xsl:template match="overview">
<info>
<xsl:for-each select="info/*">
<xsl:copy-of select="."/>
</xsl:for-each>
</info>
</xsl:template>

</xsl:stylesheet>

If you want to perform merge only in case b) extra check have to be added.

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 20 Oct 2005 10:03 PM
Hi Yuriv,

Thanks for your help. I hope you can give me some tips on how to do this.

How can I modify my stylesheet to handle this case:

Regards,

Ann Marie

input:

<concept>
<overview>
<info>
<para>A</para>
</info>
</overview>
<info>
<para>B</para>
</info>
</concept>

There are overview elements in other parts of the tree that don't want to change. I want to combine info element children of concept/overview with the info element that is the immediately following sibling of overview in a single info element.

desired output:

<concept>
<info>
<para>A</para>
<para>B</para>
</info>
</concept>

Postnext
Ivan PedruzziSubject: merge contents of consecutive duplicate elements
Author: Ivan Pedruzzi
Date: 19 Oct 2005 03:47 PM

In case you were looking to just merge the duplicates under overview/info and leave the rest as it is, take a look to the attached solution

hope this helps
Ivan Pedruzzi
Stylus Studio Team


Documentmerge-duplicates.xsl

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 20 Oct 2005 10:08 PM
thanks Ivan.

I need to merge the duplicate info elements under overview children of concept but not other info elements. See my reply to Yuriv. I'm going to try out this stylesheet and see if I can modify it to merge the info child of concept/overview with overview's following sibling info node.

that's the problem I need to solve now.

If you have any suggestions, I would greatly appreciate it.

thanks much,

Ann Marie

Postnext
(Deleted User) Subject: merge contents of consecutive duplicate elements
Author: (Deleted User)
Date: 21 Oct 2005 11:03 AM
Take a look at this example:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
<concept>
<info>
<xsl:apply-templates select="concept/overview/info/para | concept/info/para"/>
</info>
</concept>
</xsl:template>

<xsl:template match="para">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>

We can modify Ivan template to handle this case too, so you'll get original tree with info elements merged, not just sample case. But let's make sure first that we understand requirements correctly.
If you will post complete input XML with all possible cases and desired output XML we will try to come up with stylesheet.

Regards,

Yuriy

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 27 Oct 2005 01:02 PM
Hello Yuriy,

Sorry for the delay. I am attaching the input xml and desired output xml. I only want to merge the contents of subconcept/overview/info and the following-sibling info element of subconcept/overview. There are overview/info elements that are children of other elements, such as, minitask, that should be left alone.

Let me know if you have any questions about the requirements.

Regards,

Ann Marie

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 27 Oct 2005 01:12 PM
Hello Yuriy,

Sorry for the delay. I am attaching the input xml and desired output xml. I want to remove overview children of subconcept and merge the contents of subconcept/overview/info and the following-sibling info element of subconcept/overview. There are overview/info elements that are children of other elements, such as, minitask, that should be left alone.

For example, the following input:
<subconcept id="_8">
<title>concept</title>
<overview>
<info>
<para>para A</para>
</info>
</overview>
<info>
<para>para B</para>
</info>
</subconcept>

should be changed to:
<subconcept id="_8">
<title>subconcept</title>
<info>
<para>para 1</para>
<para>para 2</para>
</info>
</subconcept>
Let me know if you have any questions about the requirements.

Regards,

Ann Marie

Postnext
(Deleted User) Subject: merge contents of consecutive duplicate elements
Author: (Deleted User)
Date: 27 Oct 2005 03:06 PM
You can change Ivan XSLT (published in this thread) :

change :


<xsl:template match="overview">

into :

<xsl:template match="subconcept/overview">

and you'll get following output:


<?xml version='1.0' ?>
<document>
<doctitle>
<prodtitle>prodtitle</prodtitle>
<title>title</title>
</doctitle>
<subtitle>subtitle</subtitle>
<copyright id="_1">
<para>paragraph</para>
</copyright>
<preface>
<purpose>
<info>
<para>paragraph</para>
</info>
</purpose>
<audience>
<info>
<para>paragraph</para>
</info>
</audience>
<organization>
<info>
<para>paragraph</para>
</info>
</organization>
<relateddocumentation>
<info>
<para>paragraph</para>
</info>
</relateddocumentation>
<boilerplate id="_2">
<concept id="_3">
<title>concept</title>
<overview>
<info>
<para>overview paragraph</para>
</info>
</overview>
<subconcept>
<title>subconcept</title>
<overview><info><para>overview paragraph A</para><para>overview paragraph B</para></info></overview>
<info>
<para>test</para>
</info>
</subconcept>
<minitask>
<title>minitask title</title>
<overview>
<info>
<para>minitask overview paragraph</para>
</info>
</overview>
<minitasksteps>
<minitaskstep>
<action>action</action>
</minitaskstep>
</minitasksteps>
</minitask>
</concept>
</boilerplate>
</preface>

<section solution="all" id="_7" htmlfilename="test">
<title>test</title>
</section>
</document>


where


<subconcept>
<title>subconcept</title>
<overview>
<info>
<para>overview paragraph A</para>
<para>overview paragraph B</para>
</info>
</overview>

2 <info> tags replaced with single <info>
all <info> children are merged (<para>)
and all this happens only if <overview> is direct child of <subconcept>


Hope this will help

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 27 Oct 2005 03:25 PM
Thank you very much. I'll give it a try.

Postnext
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 28 Oct 2005 02:16 PM
Hi,

I ran Ivan's merge_duplicates.xsl with template match=subconcept/overview. The info elements are still not merged. Did I miss something?

thanks,

Ann Marie


Unknownmerge_out.xml

Postnext
(Deleted User) Subject: merge contents of consecutive duplicate elements
Author: (Deleted User)
Date: 28 Oct 2005 02:46 PM
Here is input file:

<?xml version="1.0"?>
<document>
<doctitle>
<prodtitle>prodtitle</prodtitle>
<title>title</title>
</doctitle>
<subtitle>subtitle</subtitle>
<copyright id="_1">
<para>paragraph</para>
</copyright>
<preface>
<purpose>
<info>
<para>paragraph</para>
</info>
</purpose>
<audience>
<info>
<para>paragraph</para>
</info>
</audience>
<organization>
<info>
<para>paragraph</para>
</info>
</organization>
<relateddocumentation>
<info>
<para>paragraph</para>
</info>
</relateddocumentation>
<boilerplate id="_2">
<concept id="_3">
<title>concept</title>
<overview>
<info>
<para>overview paragraph</para>
</info>
</overview>
<subconcept>
<title>subconcept</title>
<overview>
<info>
<para>overview paragraph A</para>
</info>
<info>
<para>overview paragraph B</para>
</info>
</overview>
<info>
<para>test</para>
</info>
</subconcept>
<minitask>
<title>minitask title</title>
<overview>
<info>
<para>minitask overview paragraph</para>
</info>
</overview>
<minitasksteps>
<minitaskstep>
<action>action</action>
</minitaskstep>
</minitasksteps>
</minitask>
</concept>
</boilerplate>
</preface>

<section solution="all" id="_7" htmlfilename="test">
<title>test</title>
</section>
</document>

Here is XSLT:


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="subconcept/overview">
<xsl:copy>
<info>
<xsl:apply-templates select="@*|*" mode="merge"/>
</info>
</xsl:copy>
</xsl:template>

<xsl:template match="info" mode="merge">
<xsl:apply-templates select="@*|*" mode="merge"/>
</xsl:template>

<xsl:template match="*" mode="merge">
<xsl:variable name="current" select="."/>
<xsl:if test="not(../following-sibling::info[1]/*[. = $current])">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>

<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>

<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Here is output file:



<?xml version='1.0' ?>
<document>
<doctitle>
<prodtitle>prodtitle</prodtitle>
<title>title</title>
</doctitle>
<subtitle>subtitle</subtitle>
<copyright id="_1">
<para>paragraph</para>
</copyright>
<preface>
<purpose>
<info>
<para>paragraph</para>
</info>
</purpose>
<audience>
<info>
<para>paragraph</para>
</info>
</audience>
<organization>
<info>
<para>paragraph</para>
</info>
</organization>
<relateddocumentation>
<info>
<para>paragraph</para>
</info>
</relateddocumentation>
<boilerplate id="_2">
<concept id="_3">
<title>concept</title>
<overview>
<info>
<para>overview paragraph</para>
</info>
</overview>
<subconcept>
<title>subconcept</title>
<overview><info><para>overview paragraph A</para><para>overview paragraph B</para></info></overview>
<info>
<para>test</para>
</info>
</subconcept>
<minitask>
<title>minitask title</title>
<overview>
<info>
<para>minitask overview paragraph</para>
</info>
</overview>
<minitasksteps>
<minitaskstep>
<action>action</action>
</minitaskstep>
</minitasksteps>
</minitask>
</concept>
</boilerplate>
</preface>

<section solution="all" id="_7" htmlfilename="test">
<title>test</title>
</section>
</document>


Take a look how in :

<subconcept>
<title>subconcept</title>
<overview>
<info>
<para>overview paragraph A</para>
</info>
<info>
<para>overview paragraph B</para>
</info>
</overview>
<info>
<para>test</para>
</info>
</subconcept>

2 <overview> child <info> elements were replaced with one <info> element with merged children :


<subconcept>
<title>subconcept</title>
<overview>
<info>
<para>overview paragraph A</para>
<para>overview paragraph B</para>
</info>
</overview>
<info>

Posttop
Ann Marie RubinSubject: merge contents of consecutive duplicate elements
Author: Ann Marie Rubin
Date: 28 Oct 2005 03:09 PM
Ah. This stylesheet merges para A and B given this xml input:
<overview>
<info>
<para>para A</para>
</info>
<info>
<para>para B</para>
</info>

</overview>
<info>
<para>para C</para>
</info>

To get this xml output:
<info>
<para>para A</para>
<para>para B</para>
</info>
<info>
<para>para C</para>
</info>


But, I'm trying to remove the overview element and merge para A and para C in this xml input :


<overview>
<info>
<para>para A</para>
</info>

</overview>
<info>
<para>para C</para>
</info>


To get this xml output:
<info>
<para>para A</para>
<para>para C</para>

</info>


see my attached xml input.

thanks,

Ann Marie


Unknowntest_multiconcept.xml

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.