Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xsl duplicates data

Reply
Thread Tools

xsl duplicates data

 
 
1984to911@gmail.com
Guest
Posts: n/a
 
      09-09-2008
I have an XML of the form

<grandparent>
<top_element>
data
<special_element>special data</special_element>
</top_element>

<second_element>
<some_element>some data</some_element>
<special_element>other special data </special_element>
<some_other_element>some other data</some_other_element>
<second_element>
</grandparent>

I'm trying to get html output of the form

<div>
some data
<div>other special data </div>
some other data
</div>


so far the best I can get is
<div>
some data
other special data
some other data
<div>other special data</div>
</div>

by using
<xsl:template match="second_element">
<div><xsl:value-of select="."/>

<xsl:apply-templates select=".//special_element"/>
</div>
</xsl:template>

<xsl:template match="//second_element//special_element">
<div >
<xsl:value-of select="."/></div>
</xsl:template>
 
Reply With Quote
 
 
 
 
Pavel Lepin
Guest
Posts: n/a
 
      09-10-2008

http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote in
<(E-Mail Removed)>:
> <grandparent>
> <top_element>
> data
> <special_element>special data</special_element>
> </top_element>
>
> <second_element>
> <some_element>some data</some_element>
> <special_element>other special data </special_element>
> <some_other_element>some other data</some_other_element>
> <second_element>


Not well-formed.

> </grandparent>
>
> I'm trying to get html output of the form
>
> <div>
> some data
> <div>other special data </div>
> some other data
> </div>


<xsl:stylesheet version="1.0"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates
select="grandparent/second_element"/>
</xsl:template>
<xsl:template match="second_element|special_element">
<xsl:element name="div">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

--
Waterfall - One Process To Rule Them All
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
std::list Duplicates with Different Data Mike Copeland C++ 3 05-14-2008 12:21 AM
XSL FO page-number-citation - Pruning duplicates or forcing unique jason.davidson@gmail.com XML 0 06-13-2006 08:55 PM
QUESTION: Good data structure for list within list with duplicates? basi Ruby 4 08-01-2005 07:30 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
XSL-1000: (Fatal Error) Error while parsing XSL file (org.apache.xerces.parsers.AbstractSAXParser$AttributesProxy) Kevin Flood Java 0 09-08-2004 02:11 PM



Advertisments