Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Neil Smith [MVP Digital Media]" <neil@------.--->
To: NULL
Date: 1/16/2008 12:04:00 AM

You can use &#160; instead of &nbsp; in XML

&#160; is the decimal code for a non-breaking space, which is
identical to the &nbsp; entity (that is only defined by HTML DTD)

There's no need to invoke CDATA and escaping here.

If you do have problems with the input HTML parsing correctly, run the
content through "Tidy" which has bindings for a range of languages
including .NET : See http://tidy.sourceforge.net/ and this page for
.NET specfic : http://users.rcn.com/creitzel/tidy.html#dotnet

The default settings are almost always fine for general use.

HTH
Cheers - Neil

On Tue, 15 Jan 2008 15:15:01 -0800, AlBruAn
<albruan@h....(donotspam)> 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 "&nbsp".
>
>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.
------------------------------------------------
Digital Media MVP : 2004-2008
http://mvp.support.microsoft.com/mvpfaqs


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