Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Using xsl:if with xsl:value-of

From: albruan@-------.---.(---------)
To: NULL
Date: 1/16/2008 6:26:00 AM

I finally figure it out using a combination of xsl:choose, xsl:when and 
xsl:otherwise in conjunction with the xsl:value-of statements.  Thanks again 
for your suggestion on replacing the CDATA string with &160, Neil; it makes 
for much cleaner code.
-- 
Things are more like they are now than they ever have been before.


"AlBruAn" wrote:

> I am using an open source HTML editor in an ASP.NET project to permit the 
> users to create templates for form letters.  When the user chooses to save 
> the current template, I parse the HTML to create the XSL for populating the 
> letters and I write both the HTML and XSL to the database.  Among the things 
> the user can do is incorporate a table in the form letter, inserting both 
> text and data in the table.  To maintain borders around those cells that are 
> intentionally left empty in design mode, I replace the "<td> </td>" HTML 
> string with "<td><xsl:text 
> disable-output-escaping="yes"><![CDATA[ ]]></xsl:text></td>" since XSL 
> doesn't seem to like " ".
> 
> The above works like a charm as long as there is data for all fields within 
> the table; if data for one field is missing, the border for that cell doesn't 
> match the borders of all the other cells in the table.  So my question is 
> this: how can I go about using data in the cell if any is available or 
> replacing it with the disable-output-escaping statement as shown above?  I 
> thought there might be a way of incorporating xsl:if along with xsl:value-of, 
> but I honestly don't know.  Anyway...
> 
> A portion of the XML I'm reading is as follows:
> <entity>
>     <ProviderID>12345</ProviderID>
>     <ProviderName>Butcher Burns, MD</ProviderName>
>     <ClaimNumber>1Z3ED0999</ClaimNumber>
>     <DateOfService>12/01/2005</DateOfService>
> </entity>
> <entity>
>     <ProviderID>12346</ProviderID>
>     <ProviderName>Blades Messina, MD</ProviderName>
>     <ClaimNumber>1Z3EF0000</ClaimNumber>
>     <DateOfService></DateOfService>
> </entity>
> 
> A portion of the currently-existing XSL is listed below.  The entire table 
> containing the following snippet is inside an xsl:for-each loop.
> <tr>
>    <td align="right">Claim Number:</td>
>    <td><xsl:value-of select="ClaimNumber" /></td>
>    <td align="right">Date of Service:</td>
>    <td><xsl:value-of select="DateOfService" /></td>
> </tr>
> 
> In this case, I want the fourth cell to contain the Date of Service the 
> first time through the loop since the data is provided for that iteration.  
> On the second iteration, the fourth cell needs to contain "<td><xsl:text 
> disable-output-escaping="yes"><![CDATA[ ]]></xsl:text></td>" since Date of 
> Service data isn't provided for it.
> 
> 
> -- 
> Things are more like they are now than they ever have been before.


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent