![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Last position [Thread Next] Re: Last positionTo: NULL Date: 3/31/2008 1:49:00 PM
I finally got this working correctly.
I was missing the <value></value> tags that were originally around the
<xsl:apply-templates select="../../@*"/>.
I am still confused on the indentation - which works, but I am not sure why.
My XML file:
*****************************************
<?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>
<OTHERFILENUMBER>692</OTHERFILENUMBER>
<FNMA_FILENUMBER>693</FNMA_FILENUMBER>
<SUBPROPADDRESS>3</SUBPROPADDRESS>
</FIELDS>
<FORMPHOTOS></FORMPHOTOS>
<attachments>
<attachment key="db8d208f-b049-4caa-bac0-eeb4cf9007d6" type="photo"
label="Comparable Sale #1">
<image>
<binary xmlns:dt="urn:schemas-microsoft-com:datatypes"
dt:dt="bin.base64" format="jpeg">/9j/4AAQSkZJRgA</binary>
</image>
<thumbnail>
<binary xmlns:dt="urn:schemas-microsoft-com:datatypes"
dt:dt="bin.base64" format="jpeg">/9j/4AAQSkZ</binary>
</thumbnail>
</attachment>
<attachment key="560ff252-882d-4d3e-9e0c-aa1cb7c38952" type="photo"
label="Comparable Sale #2">
<image>
<binary xmlns:dt="urn:schemas-microsoft-com:datatypes"
dt:dt="bin.base64" format="jpeg">/9j/4AAQSkZJR</binary>
</image>
<thumbnail>
<binary xmlns:dt="urn:schemas-microsoft-com:datatypes"
dt:dt="bin.base64" format="jpeg">/9j/4AAQSkZJR</binary>
</thumbnail>
</attachment>
</attachments>
</FORM>
</FORMS>
</REPORT>
*****************************************
If I do:
<xsl:apply-templates select="FORMS/FORM/attachments/attachment"/>
<xsl:template match="attachments/attachment/*">
I get (indents gone):
</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>
and I have only 2 attachments.
If I do the following where I just add the "/*" to the apply_templates so
that both match (like we did with the "FIELDS/*"), it lines them up
correctly but no data.
<xsl:apply-templates select="FORMS/FORM/attachments/attachment/*"/>
<xsl:template match="attachments/attachment/*">
I get this:
<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>
Again no data, but 4 attachments instead of 2.
If I do:
<xsl:apply-templates select="FORMS/FORM/attachments/attachment"/>
<xsl:template match="attachments/attachment">
Then it works fine (data and indents):
<attachment>
<key>db8d208f-b049-4caa-bac0-eeb4cf9007d6</key>
<type>photo</type>
<label>Comparable Sale #1</label>
<imageFormat>jpeg</imageFormat>
<imageText>/9j/4AAQSkZJRgA</imageText>
<thumbnailFormat>jpeg</thumbnailFormat>
<thumbnailImage>/9j/4AAQSkZ</thumbnailImage>
<sourceFormat></sourceFormat>
<sourceKey></sourceKey>
<sourceText></sourceText>
</attachment>
<attachment>
<key>560ff252-882d-4d3e-9e0c-aa1cb7c38952</key>
<type>photo</type>
<label>Comparable Sale #2</label>
<imageFormat>jpeg</imageFormat>
<imageText>/9j/4AAQSkZJR</imageText>
<thumbnailFormat>jpeg</thumbnailFormat>
<thumbnailImage>/9j/4AAQSkZJR</thumbnailImage>
<sourceFormat></sourceFormat>
<sourceKey></sourceKey>
<sourceText></sourceText>
</attachment>
<
Why did I need the "/*" in the fields example and not here in this one?
And why did the indents disappear?
Thanks,
Tom
"tshad" <tshad@d...> wrote in message
news:%23QQF$x1kIHA.464@T......
>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 | |||||
|
