|
|
|
date: Mon, 21 Apr 2008 10:27:10 -0700,
group: microsoft.public.xsl
back
template not getting called
I have a template that I was building with Martins help a couple of weeks
ago, but can't seem to get the 1st template to work.
In essence it is supposed to handle all the elements that DON'T start with
various text. Those elements are handled following this template.
But for some reason the template doesn't seem to be getting called.
The test xml I am using is:
<?xml version="1.0" encoding="utf-8"?>
<REPORT VERSION="1.10" FILENUM="" DESCRIPTION="Form Utility XML: 3/18/2008
12:27:13 PM" MAJORFORM="1004">
<ORDER></ORDER>
<TRACKING></TRACKING>
<FORMS>
<FORM NUM="1" FORMCODE="1004" SECCODE="1" DESC="" MAJOR="True">
<FIELDS>
<EXTRAFIELD>Extra</EXTRAFIELD>
<OTHERFILENUMBER>692</OTHERFILENUMBER>
<FNMA_FILENUMBER>693</FNMA_FILENUMBER>
<SUBPROPADDRESS>3</SUBPROPADDRESS>
<SCMCOMMENTS_1>This is a test line 1</SCMCOMMENTS_1>
<SCMCOMMENTS_2>This is a test line 2</SCMCOMMENTS_2>
<SCMCOMMENTS_3>This is a test line 3</SCMCOMMENTS_3>
<SCMCOMMENTS_4>This is a test line 4</SCMCOMMENTS_4>
<GEN_COMMENTS_1>SALES COMPARISON COMMENTS (cont.)</GEN_COMMENTS_1>
<GEN_COMMENTS_2>test 2</GEN_COMMENTS_2>
<GEN_COMMENTS_3>test 3</GEN_COMMENTS_3>
<GEN_COMMENTS_4>test 4</GEN_COMMENTS_4>
<GEN_COMMENTS_5 />
<GEN_COMMENTS_6 />
<GEN_COMMENTS_7 />
<GEN_COMMENTS_8 />
<GEN_COMMENTS_9 />
<CMPHIST_TXT>The test line1</CMPHIST_TXT>
<CMPHIST_TXT2>The test line2</CMPHIST_TXT2>
<CMPHIST_TXT3>The test line3</CMPHIST_TXT3>
<CMPHIST_TXT4>The test line4</CMPHIST_TXT4>
</FIELDS>
</FORMS>
</REPORT>
These elements don't seem to be getting handled:
<EXTRAFIELD>Extra</EXTRAFIELD>
<OTHERFILENUMBER>692</OTHERFILENUMBER>
<FNMA_FILENUMBER>693</FNMA_FILENUMBER>
<SUBPROPADDRESS>3</SUBPROPADDRESS>
All the others are.
The template is:
******************************************************
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates
select="FORMS/FORM/FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and
not(starts-with(name(), 'GEN_COMMENTS')) and
not(starts-with(name(), 'CMPHIST_TXT'))]"/>
<form>
<sectionNumber>0</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="FORMS/FORM/@FORMCODE"/>
</formName>
<tagName>SCMCOMMENTS_1</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
'SCMCOMMENTS')]"/>
</value>
</form>
<form>
<sectionNumber>0</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="FORMS/FORM/@FORMCODE"/>
</formName>
<tagName>GEN_COMMENTS_1</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
'GEN_COMMENTS')]"/>
</value>
</form>
<form>
<sectionNumber>0</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="FORMS/FORM/@FORMCODE"/>
</formName>
<tagName>CMPHIST_TXT</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
'CMPHIST_TXT')]"/>
</value>
</form>
<form>
<sectionNumber>
<xsl:value-of select="FORMS/FORM/@SECCODE"/>
</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="FORMS/FORM/@FORMCODE"/>
</formName>
<tagName>FormFormats</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:apply-templates select="FORMS/FORM/@*"/>
</value>
</form>
<xsl:apply-templates select="FORMS/FORM/attachments/attachment"/>
</xsl:copy>
</xsl:template>
<xsl:template match="FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and
not(starts-with(name(), 'GEN_COMMENTS')) and
not(starts-with(name(), 'CMPHIST_TXT'))]">
<form>
<sectionNumber>
<xsl:text>0</xsl:text>
</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="../../@FORMCODE"/>
</formName>
<tagName>
<xsl:value-of select="name()"/>
</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:value-of select="."/>
</value>
</form>
</xsl:template>
<xsl:template match="FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="FIELDS/*[starts-with(name(), 'GEN_COMMENTS')]">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="FIELDS/*[starts-with(name(), 'CMPHIST_TXT')]">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="FORM/@*">
<xsl:value-of select="concat(name(), '=', .)"/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
******************************************************
I also tried the following where the template only has FIELDS/* in it
instead of FORMS/FORM/FIELDS/*
*************************************************************
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates
select="FORMS/FORM/FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and
not(starts-with(name(), 'GEN_COMMENTS')) and
not(starts-with(name(), 'CMPHIST_TXT'))]"/>
<form>
<sectionNumber>0</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="FORMS/FORM/@FORMCODE"/>
</formName>
<tagName>SCMCOMMENTS_1</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
'SCMCOMMENTS')]"/>
</value>
</form>
<form>
<sectionNumber>0</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="FORMS/FORM/@FORMCODE"/>
</formName>
<tagName>GEN_COMMENTS_1</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
'GEN_COMMENTS')]"/>
</value>
</form>
<form>
<sectionNumber>0</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="FORMS/FORM/@FORMCODE"/>
</formName>
<tagName>CMPHIST_TXT</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
'CMPHIST_TXT')]"/>
</value>
</form>
<form>
<sectionNumber>
<xsl:value-of select="FORMS/FORM/@SECCODE"/>
</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="FORMS/FORM/@FORMCODE"/>
</formName>
<tagName>FormFormats</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:apply-templates select="FORMS/FORM/@*"/>
</value>
</form>
<xsl:apply-templates select="FORMS/FORM/attachments/attachment"/>
</xsl:copy>
</xsl:template>
<xsl:template match="FORMS/FORM/FIELDS/*[not(starts-with(name(),
'SCMCOMMENTS')) and
not(starts-with(name(), 'GEN_COMMENTS')) and
not(starts-with(name(), 'CMPHIST_TXT'))]">
<form>
<sectionNumber>
<xsl:text>0</xsl:text>
</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="../../@FORMCODE"/>
</formName>
<tagName>
<xsl:value-of select="name()"/>
</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:value-of select="."/>
</value>
</form>
</xsl:template>
<xsl:template match="FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="FIELDS/*[starts-with(name(), 'GEN_COMMENTS')]">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="FIELDS/*[starts-with(name(), 'CMPHIST_TXT')]">
<xsl:value-of select="."/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="FORM/@*">
<xsl:value-of select="concat(name(), '=', .)"/>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
**************************************************
The test is exactly the same, so why isn't it being called?
Thanks,
Tom
date: Mon, 21 Apr 2008 10:27:10 -0700
author: tshad
Re: template not getting called
Nevermind.
It was working. Just working on the wrong file. I was reading in a file
before the test file and that was the result I was getting.
Sorry,
Tom
"tshad" wrote in message
news:ee%23aqV9oIHA.4904@TK2MSFTNGP03.phx.gbl...
>I have a template that I was building with Martins help a couple of weeks
>ago, but can't seem to get the 1st template to work.
>
> In essence it is supposed to handle all the elements that DON'T start with
> various text. Those elements are handled following this template.
>
> But for some reason the template doesn't seem to be getting called.
>
> The test xml I am using is:
>
> <?xml version="1.0" encoding="utf-8"?>
> <REPORT VERSION="1.10" FILENUM="" DESCRIPTION="Form Utility XML: 3/18/2008
> 12:27:13 PM" MAJORFORM="1004">
> <ORDER></ORDER>
> <TRACKING></TRACKING>
> <FORMS>
> <FORM NUM="1" FORMCODE="1004" SECCODE="1" DESC="" MAJOR="True">
> <FIELDS>
> <EXTRAFIELD>Extra</EXTRAFIELD>
> <OTHERFILENUMBER>692</OTHERFILENUMBER>
> <FNMA_FILENUMBER>693</FNMA_FILENUMBER>
> <SUBPROPADDRESS>3</SUBPROPADDRESS>
> <SCMCOMMENTS_1>This is a test line 1</SCMCOMMENTS_1>
> <SCMCOMMENTS_2>This is a test line 2</SCMCOMMENTS_2>
> <SCMCOMMENTS_3>This is a test line 3</SCMCOMMENTS_3>
> <SCMCOMMENTS_4>This is a test line 4</SCMCOMMENTS_4>
> <GEN_COMMENTS_1>SALES COMPARISON COMMENTS (cont.)</GEN_COMMENTS_1>
> <GEN_COMMENTS_2>test 2</GEN_COMMENTS_2>
> <GEN_COMMENTS_3>test 3</GEN_COMMENTS_3>
> <GEN_COMMENTS_4>test 4</GEN_COMMENTS_4>
> <GEN_COMMENTS_5 />
> <GEN_COMMENTS_6 />
> <GEN_COMMENTS_7 />
> <GEN_COMMENTS_8 />
> <GEN_COMMENTS_9 />
> <CMPHIST_TXT>The test line1</CMPHIST_TXT>
> <CMPHIST_TXT2>The test line2</CMPHIST_TXT2>
> <CMPHIST_TXT3>The test line3</CMPHIST_TXT3>
> <CMPHIST_TXT4>The test line4</CMPHIST_TXT4>
> </FIELDS>
> </FORMS>
> </REPORT>
>
> These elements don't seem to be getting handled:
>
> <EXTRAFIELD>Extra</EXTRAFIELD>
> <OTHERFILENUMBER>692</OTHERFILENUMBER>
> <FNMA_FILENUMBER>693</FNMA_FILENUMBER>
> <SUBPROPADDRESS>3</SUBPROPADDRESS>
>
> All the others are.
>
> The template is:
> ******************************************************
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xsl:output method="xml" indent="yes"/>
>
> <xsl:template match="/*">
> <xsl:copy>
> <xsl:apply-templates
> select="FORMS/FORM/FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and
> not(starts-with(name(), 'GEN_COMMENTS')) and
> not(starts-with(name(), 'CMPHIST_TXT'))]"/>
> <form>
> <sectionNumber>0</sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="FORMS/FORM/@FORMCODE"/>
> </formName>
> <tagName>SCMCOMMENTS_1</tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
> 'SCMCOMMENTS')]"/>
> </value>
> </form>
> <form>
> <sectionNumber>0</sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="FORMS/FORM/@FORMCODE"/>
> </formName>
> <tagName>GEN_COMMENTS_1</tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
> 'GEN_COMMENTS')]"/>
> </value>
> </form>
> <form>
> <sectionNumber>0</sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="FORMS/FORM/@FORMCODE"/>
> </formName>
> <tagName>CMPHIST_TXT</tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
> 'CMPHIST_TXT')]"/>
> </value>
> </form>
> <form>
> <sectionNumber>
> <xsl:value-of select="FORMS/FORM/@SECCODE"/>
> </sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="FORMS/FORM/@FORMCODE"/>
> </formName>
> <tagName>FormFormats</tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:apply-templates select="FORMS/FORM/@*"/>
> </value>
> </form>
> <xsl:apply-templates select="FORMS/FORM/attachments/attachment"/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template match="FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and
> not(starts-with(name(), 'GEN_COMMENTS')) and
> not(starts-with(name(), 'CMPHIST_TXT'))]">
> <form>
> <sectionNumber>
> <xsl:text>0</xsl:text>
> </sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="../../@FORMCODE"/>
> </formName>
> <tagName>
> <xsl:value-of select="name()"/>
> </tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:value-of select="."/>
> </value>
> </form>
> </xsl:template>
>
> <xsl:template match="FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]">
> <xsl:value-of select="."/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
> <xsl:template match="FIELDS/*[starts-with(name(), 'GEN_COMMENTS')]">
> <xsl:value-of select="."/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
> <xsl:template match="FIELDS/*[starts-with(name(), 'CMPHIST_TXT')]">
> <xsl:value-of select="."/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
>
> <xsl:template match="FORM/@*">
> <xsl:value-of select="concat(name(), '=', .)"/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
>
> </xsl:stylesheet>
>
> ******************************************************
>
> I also tried the following where the template only has FIELDS/* in it
> instead of FORMS/FORM/FIELDS/*
>
> *************************************************************
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xsl:output method="xml" indent="yes"/>
>
> <xsl:template match="/*">
> <xsl:copy>
> <xsl:apply-templates
> select="FORMS/FORM/FIELDS/*[not(starts-with(name(), 'SCMCOMMENTS')) and
> not(starts-with(name(), 'GEN_COMMENTS')) and
> not(starts-with(name(), 'CMPHIST_TXT'))]"/>
> <form>
> <sectionNumber>0</sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="FORMS/FORM/@FORMCODE"/>
> </formName>
> <tagName>SCMCOMMENTS_1</tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
> 'SCMCOMMENTS')]"/>
> </value>
> </form>
> <form>
> <sectionNumber>0</sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="FORMS/FORM/@FORMCODE"/>
> </formName>
> <tagName>GEN_COMMENTS_1</tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
> 'GEN_COMMENTS')]"/>
> </value>
> </form>
> <form>
> <sectionNumber>0</sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="FORMS/FORM/@FORMCODE"/>
> </formName>
> <tagName>CMPHIST_TXT</tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:apply-templates select="FORMS/FORM/FIELDS/*[starts-with(name(),
> 'CMPHIST_TXT')]"/>
> </value>
> </form>
> <form>
> <sectionNumber>
> <xsl:value-of select="FORMS/FORM/@SECCODE"/>
> </sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="FORMS/FORM/@FORMCODE"/>
> </formName>
> <tagName>FormFormats</tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:apply-templates select="FORMS/FORM/@*"/>
> </value>
> </form>
> <xsl:apply-templates select="FORMS/FORM/attachments/attachment"/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template match="FORMS/FORM/FIELDS/*[not(starts-with(name(),
> 'SCMCOMMENTS')) and
> not(starts-with(name(), 'GEN_COMMENTS')) and
> not(starts-with(name(), 'CMPHIST_TXT'))]">
> <form>
> <sectionNumber>
> <xsl:text>0</xsl:text>
> </sectionNumber>
> <primary>True</primary>
> <formName>
> <xsl:value-of select="../../@FORMCODE"/>
> </formName>
> <tagName>
> <xsl:value-of select="name()"/>
> </tagName>
> <flags>0</flags>
> <format>0</format>
> <value>
> <xsl:value-of select="."/>
> </value>
> </form>
> </xsl:template>
>
> <xsl:template match="FIELDS/*[starts-with(name(), 'SCMCOMMENTS')]">
> <xsl:value-of select="."/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
> <xsl:template match="FIELDS/*[starts-with(name(), 'GEN_COMMENTS')]">
> <xsl:value-of select="."/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
> <xsl:template match="FIELDS/*[starts-with(name(), 'CMPHIST_TXT')]">
> <xsl:value-of select="."/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
>
> <xsl:template match="FORM/@*">
> <xsl:value-of select="concat(name(), '=', .)"/>
> <xsl:if test="position() != last()">
> <xsl:text> </xsl:text>
> </xsl:if>
> </xsl:template>
>
> </xsl:stylesheet>
> **************************************************
>
> The test is exactly the same, so why isn't it being called?
>
> Thanks,
>
> Tom
>
>
date: Mon, 21 Apr 2008 11:04:10 -0700
author: tshad
|
|