transformation quits after third apply-templates
Posted: Wed Jun 24, 2009 8:09 am
Hi,
Having a problem with transforming code.
I need to select elements based on their (one) parent's attribute, and insert a unique attribute in each element.
Here is the xsl:
Here is some partial xml:
I know the answer is probably simple, so thanks for taking time to help.
Having a problem with transforming code.
I need to select elements based on their (one) parent's attribute, and insert a unique attribute in each element.
Here is the xsl:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<--here I need to recreate the cam element while inserting a namespace declaration-->
<xsl:template match="cam">
<cam xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">
<xsl:apply-templates/>
</cam>
</xsl:template>
<--listing is a child of cam, these represent records from a database; the only thing that changes is the member type. I want to add attributes to listing's children based on each unique member_type attribute.-->
<xsl:template match="listing[@MEMBER_TYPE='CPB']/COMPANY">
<company>
<xsl:attribute name="aid:pstyle">Head_Bronze</xsl:attribute>
<xsl:value-of select="."/>
</company>
<xsl:apply-templates/>
</xsl:template>
<--that worked fine, but instead of moving on to the next template, the transformation simply stops. The code below is not executed.-->
<xsl:template match="listing[@MEMBER_TYPE='CPG']/COMPANY">
<company>
<xsl:attribute name="aid:pstyle">Head_Gold</xsl:attribute>
<xsl:value-of select="."/>
</company>
<xsl:apply-templates/>
</xsl:template>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<cam>
<listing MEMBER_TYPE="CPB">
<FULL_NAME>Ms. Rebecca Sunny</FULL_NAME>
<COMPANY>ABC Company</COMPANY>
</listing>
<listing MEMBER_TYPE="CPG">
<FULL_NAME>Brook Farms</FULL_NAME>
<COMPANY>XYZ</COMPANY>
</listing>