![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Last position >Thread Next - Re: Last position Re: Last positionTo: NULL Date: 3/31/2008 11:22:00 AM
I almost have it (but not sure why the indents work here and not before)
"tshad" <tshad@d...> wrote in message
news:%23FVN4o1kIHA.4120@T......
> This is the 2nd question using the same answer you gave here.
>
<snip>
I added another apply-template and after a few tries got it close:
*****************************************************
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="REPORT">
<xsl:copy>
<xsl:apply-templates select="FORMS/FORM/FIELDS/*"/>
<xsl:apply-templates select="FORMS/FORM/attachments/attachment/*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="FIELDS/*">
<form>
<sectionNumber>
<xsl:value-of select="../../@SECCODE"/>
</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:if test="position()=last()">
<form>
<sectionNumber>
<xsl:value-of select="../../@SECCODE"/>
</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="../../@FORMCODE"/>
</formName>
<tagName>FormFormats</tagName>
<flags>0</flags>
<format>0</format>
<xsl:apply-templates select="../../@*"/>
</form>
</xsl:if>
</xsl:template>
<xsl:template match="attachments/attachment/*">
<attachment>
<key>
<xsl:value-of select="@key"/>
</key>
<type>
<xsl:value-of select="@type"/>
</type>
<label>
<xsl:value-of select="@label"/>
</label>
<imageFormat>
<xsl:value-of select="image/binary/@format"/>
</imageFormat>
<imageText>
<xsl:value-of select="image/binary/text()"/>
</imageText>
<thumbnailFormat>
<xsl:value-of select="thumbnail/binary/@format"/>
</thumbnailFormat>
<thumbnailImage>
<xsl:value-of select="thumbnail/binary/text()"/>
</thumbnailImage>
<sourceFormat>
<xsl:value-of select="source/@format"/>
</sourceFormat>
<sourceKey>
<xsl:value-of select="source/@key"/>
</sourceKey>
<sourceText>
<xsl:value-of select="source/binary/text()"/>
</sourceText>
</attachment>
</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 only real change was adding the following line (after realizing it was
case sensitive):
<xsl:apply-templates select="FORMS/FORM/attachments/attachment/*"/>
and the result is fine - except it now seems to have lost the <form></form>
around the extra form element you created and it lost the indentation for
that line.
**********************************************************
<?xml version="1.0" encoding="utf-8"?>
<REPORT>
<form>
<sectionNumber>1</sectionNumber>
<primary>True</primary>
<formName>1004</formName>
<tagName>OTHERFILENUMBER</tagName>
<flags>0</flags>
<format>0</format>
<value>692</value>
</form>
<form>
<sectionNumber>1</sectionNumber>
<primary>True</primary>
<formName>1004</formName>
<tagName>FNMA_FILENUMBER</tagName>
<flags>0</flags>
<format>0</format>
<value>693</value>
</form>
<form>
<sectionNumber>1</sectionNumber>
<primary>True</primary>
<formName>1004</formName>
<tagName>SUBPROPADDRESS</tagName>
<flags>0</flags>
<format>0</format>
<value>3</value>
</form>
<form>
<sectionNumber>1</sectionNumber>
<primary>True</primary>
<formName>1004</formName>
<tagName>FormFormats</tagName>
<flags>0</flags>
<format>0</format>NUM=1 FORMCODE=1004 SECCODE=1 DESC= MAJOR=True</form>
<attachment>
<key></key>
<type></type>
<label></label>
<imageFormat></imageFormat>
<imageText></imageText>
<thumbnailFormat></thumbnailFormat>
<thumbnailImage></thumbnailImage>
<sourceFormat></sourceFormat>
<sourceKey></sourceKey>
<sourceText></sourceText>
</attachment>
<attachment>
<key></key>
<type></type>
<label></label>
<imageFormat></imageFormat>
<imageText></imageText>
<thumbnailFormat></thumbnailFormat>
<thumbnailImage></thumbnailImage>
<sourceFormat></sourceFormat>
<sourceKey></sourceKey>
<sourceText></sourceText>
</attachment>
<attachment>
<key></key>
<type></type>
<label></label>
<imageFormat></imageFormat>
<imageText></imageText>
<thumbnailFormat></thumbnailFormat>
<thumbnailImage></thumbnailImage>
<sourceFormat></sourceFormat>
<sourceKey></sourceKey>
<sourceText></sourceText>
</attachment>
<attachment>
<key></key>
<type></type>
<label></label>
<imageFormat></imageFormat>
<imageText></imageText>
<thumbnailFormat></thumbnailFormat>
<thumbnailImage></thumbnailImage>
<sourceFormat></sourceFormat>
<sourceKey></sourceKey>
<sourceText></sourceText>
</attachment>
</REPORT>
***********************************************************
I separated the problem line by a couple of lines so it would stand out. As
you can see it is missing the <form> tags - which is why I assume it also
didn't indent correctly.
I'll try a couple of other things and maybe stumble on it.
Thanks,
Tom
>
> Thanks,
>
> Tom
>> --
>>
>> Martin Honnen --- MVP XML
>> http://JavaScript.FAQTs.com/
>
>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
