[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

trying to create surrounding element

Subject: trying to create surrounding element
From: Andreas Peter <info@xxxxxxxxxx>
Date: Sun, 08 Jun 2008 18:59:55 +0200
 trying to create surrounding element
Hello list users,

this is my xml file:

<?xml version="1.0" encoding="UTF-8"?>
<aaa>
   <bbb>
       <ccc>
           <ddd attribute="boxtype_start"/>
       </ccc>
       <eee>box1_start</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxh1"/>
       </ccc>
       <eee>1_boxtitle_h1</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxh2"/>
       </ccc>
       <eee>1_boxtitle_h2</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxpara"/>
       </ccc>
       <eee>boxpara</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxtype_end"/>
       </ccc>
       <eee>box1_end</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxtype_start"/>
       </ccc>
       <eee>box2_start</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxh1"/>
       </ccc>
       <eee>2_boxtitle_h1</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxh2">test</ddd>
       </ccc>
       <eee>2_boxtitle_h2</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxpara"/>
       </ccc>
       <eee>boxpara</eee>
   </bbb>
   <bbb>
       <ccc>
           <ddd attribute="boxtype_end"/>
       </ccc>
       <eee>box2_end</eee>
   </bbb>
</aaa>


This my xsl file:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">


<xsl:output indent="yes"/>

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

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

   <xsl:template match="bbb">
       <xsl:if test="descendant::*[@attribute='boxh1']">
           <title>
               <xsl:apply-templates select="eee"/>
           </title>
       </xsl:if>
       <xsl:if test="descendant::*[@attribute='boxh2']">
           <subtitle>
               <xsl:apply-templates select="eee"/>
           </subtitle>
       </xsl:if>
       <xsl:if test="descendant::*[@attribute='boxpara']">
           <para>
               <xsl:apply-templates select="eee"/>
           </para>
       </xsl:if>
   </xsl:template>

</xsl:stylesheet>

I am trying to create a surrounding element box, depending on the contents of the element <eee> (box1_start | box2_start) so that the result looks like the following:

<?xml version="1.0" encoding="UTF-8"?>
   <box> <!-- box1_start -->
   <title>1_boxtitle_h1</title>
   <subtitle>1_boxtitle_h2</subtitle>
   <para>boxpara</para>
   </box

   <box> <!-- box2_start -->
   <title>2_boxtitle_h1</title>
   <subtitle>2_boxtitle_h2</subtitle>
   <para>boxpara</para>
  </box>

I would be very thankful for any suggestions according to my problem.

Thanks in advance,
Andreas

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.