Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Does name exist >Thread Next - Re: Does name exist Re: Does name existTo: NULL Date: 8/5/2009 12:31:00 PM
I figured out how to do this by:
<source>
<xsl:if test="../../FIELDS/HEADER">
<xsl:value-of select="../../FIELDS/HEADER"/>
</xsl:if>
<xsl:if test="../../FIELDS/*[name() =
concat('TITLE',current()/@NUM)]">
<xsl:value-of select="../../FIELDS/*[name() =
concat('TITLE',current()/@NUM)]"/>
</xsl:if>
</source>
But what I found that when both exists, it concatenates the 2nd test with
the first so that I end up with:
Subject Photo PageThis is Title1
Subject Photo Page
Subject Photo PageThis is Title3
How do you tell it to delete what is there (in the 1st and 3rd case) and put
the new value there.?
I could put 2 tests in the first part, but I would prefer to write out the
Headers text and if the 2nd test passes to overwrite what the Header test
put there. So I would end up with:
This is Title1
Subject Photo Page
This is Title3
Thanks,
Tom
"tshad" <toms@p...> wrote in message
news:uZ9YNkfFKHA.1488@T......
> How would you test if something exists?
>
> If you have:
>
> <FORM>
> <FIELDS>
> <HEADER>Subject Photo Page</HEADER>
> <TITLE1>This is Title1</TITLE1>
> <TITLE3>This is Title3</TITLE3>
> </FIELDS>
> <FORMPHOTOS>
> <PHOTO NUM="1">
> <FILENAME>09May001.jpg</FILENAME>
> <FILETYPE>JPEG</FILETYPE>
> </PHOTO>
> <PHOTO NUM="2">
> <FILENAME>09005.jpg</FILENAME>
> <FILETYPE>JPEG</FILETYPE>
> </PHOTO>
> <PHOTO NUM="3">
> <FILENAME>09002.jpg</FILENAME>
> <FILETYPE>JPEG</FILETYPE>
> </PHOTO>
> </FORMPHOTOS>
> </FORM>
>
> And I want to test if a name exists:
>
> Something like:
>
> <xsl:template match="FORMPHOTOS/PHOTO">
> <xsl:choose>
> <xsl:when test=". != ''">
> <attachment>
> <source>
> <xsl:choose>
>
> <xsl:when test="name() = concat('TITLE',current()/@NUM) exists">
> <--------
>
> <xsl:value-of select="../../FIELDS/*[name() =
> concat('TITLE',current()/@NUM)]"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="../../FIELDS/HEADER"/>
> </xsl:otherwise>
> </xsl:choose>
> </source>
> </attachment>
> </xsl:when>
> </xsl:choose>
> </xsl:template>
>
> What I want to happen here is that for the nodes that have NUM = 1 or 3 to
> use TITLE1 and TITLE3 (since they exist), otherwise use HEADER.
>
> Thanks,
>
> Tom
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
