Your solution is working but only if I add yours to mine.
If I change my template (SALE/*) to mimic yours, I get:
Code:
<xsl:template match="SALE/*">
<xsl:param name="reportName"/>
<xsl:apply-templates>
<xsl:with-param name="reportName" select="$reportName"/>
</xsl:apply-templates>
<xsl:choose>
<xsl:when test="name() = 'ADJUSTMENT'">
<form>
<section>
...
This gives me the same results I show in my earlier post, which is still missing the formName. If I look at $reportName, it is blank.
If I then add your code in, then it works. What happens is it jumps to your code (SALE) and then to mine (SALE/*), which now shows the $reportName as "Form102".
Why didn't mine work with the same code you had in yours?
Also, I noticed that in my watch window, I see $reportName as {Dimension:[1]} when it was working and as "" when I leave your code out.
I now changed the code as:
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL]
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates select="METHODS/COMPARISON/SALE">
<xsl:with-param name="reportName" select="REPORT/@MajorFormType"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<!-- Now we handle the other sections after the DATA section -->
<xsl:template match="SALE/*">
<xsl:param name="reportName"/>
<xsl:apply-templates>
<xsl:with-param name="reportName" select="$reportName"/>
</xsl:apply-templates>
<xsl:choose>
<xsl:when test="name() = 'ADJUSTMENT'">
<form>
<section>
<xsl:value-of select="../@SequenceId"/>
</section>
<formName>
<xsl:value-of select="$reportName"/>
</formName>
<tagName>
<xsl:value-of select="@Type"/>
</tagName>
<value>
<xsl:value-of select="@Description"/>
</value>
</form>
</xsl:when>
<xsl:when test="name() = 'LOCATION'">
<xsl:if test="@Address">
<form>
<section>
<xsl:value-of select="../@SequenceId"/>
</section>
<formName>
<xsl:value-of select="$reportName"/>
</formName>
<tagName>
<xsl:text>Address</xsl:text>
</tagName>
<value>
<xsl:value-of select="@Address"/>
</value>
</form>
</xsl:if>
<xsl:if test="@Address2">
<form>
<sectionNumber>
<xsl:value-of select="../@SequenceId"/>
</sectionNumber>
<formName>
<xsl:value-of select="$reportName"/>
</formName>
<tagName>
<xsl:text>Address2</xsl:text>
</tagName>
<value>
<xsl:value-of select="@Address2"/>
</value>
</form>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="SALE">
<xsl:param name="reportName"/>
<xsl:apply-templates>
<xsl:with-param name="reportName" select="$reportName"/>
</xsl:apply-templates>
</xsl:template>
</xsl:stylesheet>
This one works but if you take out or comment out your template section, the reportName is blank.
The results I get are:
Code:
<?xml version="1.0" encoding="utf-8"?>
<RESPONSE>
<form>
<section>0</section>
<formName>Form102</formName>
<tagName>Address</tagName>
<value>9107 Forest Ct</value>
</form>
<form>
<sectionNumber>0</sectionNumber>
<formName>Form102</formName>
<tagName>Address2</tagName>
<value>Franklin, CT</value>
</form>
<form>
<section>0</section>
<formName>Form102</formName>
<tagName>Concessions</tagName>
<value></value>
</form>
</RESPONSE>
Not sure why it uses the built in code.
I am using the (SALE/*) to make sure I get the children. If I didn't do that it only seemed to get me the SALE tag.
Thanks,
Tom