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::*[(_at_)attribute='boxh1']">
<title>
<xsl:apply-templates select="eee"/>
</title>
</xsl:if>
<xsl:if test="descendant::*[(_at_)attribute='boxh2']">
<subtitle>
<xsl:apply-templates select="eee"/>
</subtitle>
</xsl:if>
<xsl:if test="descendant::*[(_at_)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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--