PDA

View Full Version : Rich Text Format in XSL??


steamngn
11-10-2005, 01:09 PM
Hi All,
Haven't been here in a bit, and once again I am in need of the Guru's of xsl. I have an SQL database that has a text column in it; the text is stored in RTF format. I need to display this text in our app, which uses an xsl sheet. At present when we add the text to the page it has all of the RTF tags before and after the text, really hard to read. Is there a way to either use the RTF tags or strip them off so the text is legible?:confused:

Alex Vincent
11-10-2005, 03:35 PM
Wow. I'm no XSL expert, but what you're talking about sounds a mite interesting.

Could you provide samples of what you have to work with (input and transformation), and the current output?

steamngn
11-11-2005, 04:29 AM
Hey Alex,
Ok, a portion of the xsl sheet is posted below. After a little more thinking I guess this will be slightly more involved than I first thought. What this sheet does is open a zoom screen inside an app that we run. The select data for each query is pulled from columns in an SQL table. The query select data is defined from within the app;Specifically, query9 will pull one column from a table that is a text column, and the string of text will be in RTF format, something like
{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil Arial;}{\f1\fnil\fcharset0 Arial;}} \viewkind4\uc1\pard\lang1033\f0\fs16 Older maytag dish washer, door springs broken\par \f1 Unit needs to be replaced\f0\par }
I guess what we need to do is test to see if the data from each column is in this format, and then if it is, display it accordingly (if possible). The zoom screen is opening in IE6 engine window.
Andy

<!-- ====================================================================== -->
<!-- Section K) Division for Query9 - Service History (Query 9) -->
<!-- ====================================================================== -->

<DIV id="Query9Div" style="display: none">

<!-- Section heading -->
<TABLE WIDTH="98%" ALIGN="center" BORDER="0" CELLSPACING="2" CELLPADDING="3" BGCOLOR="#637994">
<TR><TD>
<FONT COLOR="#ffffff" SIZE="2"><B>
<xsl:value-of select="/zoom/query9/@query_label"/>:
</B></FONT>
</TD></TR>
</TABLE>

<!-- Column display labels -->
<TABLE WIDTH="98%" ALIGN="center" BORDER="0" CELLSPACING="1" CELLPADDING="3" BGCOLOR="#858573">

<!-- For each field label -->
<TR ALIGN="CENTER">
<xsl:for-each select="/zoom/query9[position()=1]/*">
<TD BGCOLOR="#B5B5A6" STYLE="FONT-SIZE: 8pt; HEIGHT: 8px;" WIDTH="1%">
<xsl:attribute name="NOWRAP"/>
<SMALL><xsl:value-of select="@display_label"/></SMALL>
</TD>
</xsl:for-each>
<TD BGCOLOR="#B5B5A6" STYLE="FONT-SIZE: 8pt; HEIGHT: 8px;" WIDTH="1%">
<xsl:attribute name="NOWRAP"/>
<SMALL>Copy Info</SMALL>
</TD>
</TR>

<!-- For each field value -->
<xsl:for-each select="/zoom/query9">

<TR ALIGN="CENTER">
<xsl:for-each select="./*">
<xsl:choose>

<!-- CUST_NO - Test and add hyperlink when it is not empty -->
<xsl:when test="(name()='CUST_NO') and not(node()='')">
<TD BGCOLOR="White" STYLE="height: 8px; FONT-SIZE: 8pt;" WIDTH="1%">
<a href="javascript: void(0);">
<xsl:attribute name="onclick">fnViewCustomer('<xsl:value-of select="."/>');
</xsl:attribute><xsl:value-of select="."/>
</a>
</TD>
</xsl:when>

<!-- ITEM_NO - Test and add hyperlink when it is not empty -->
<xsl:when test="(name()='ITEM_NO' or name()='SUBST_ITEM_NO') and not(node()='')">
<TD BGCOLOR="White" STYLE="height: 8px; FONT-SIZE: 8pt;" WIDTH="1%">
<a href="javascript: void(0);">
<xsl:attribute name="onclick">fnViewItem('<xsl:value-of select="."/>');
</xsl:attribute><xsl:value-of select="."/>
</a>
</TD>
</xsl:when>

<!-- PO_NO - Test and add hyperlink when it is not empty -->
<xsl:when test="(name()='PO_NO' or name()='LST_ORD_PO_NO' or name()='LST_RECV_PO_NO' or name()='NXT_EXPECTD_PO') and not(node()='')">
<TD BGCOLOR="White" STYLE="height: 8px; FONT-SIZE: 8pt;" WIDTH="1%">
<a href="javascript: void(0);">
<xsl:attribute name="onclick">fnViewPO('<xsl:value-of select="."/>');
</xsl:attribute><xsl:value-of select="."/>
</a>
</TD>
</xsl:when>

<!-- RECVR_NO - Test and add hyperlink when it is not empty -->
<xsl:when test="(name()='RECVR_NO' or name()='PO_RECVR_NO') and not(node()='')">
<TD BGCOLOR="White" STYLE="height: 8px; FONT-SIZE: 8pt;" WIDTH="1%">
<a href="javascript: void(0);">
<xsl:attribute name="onclick">fnViewReceiver('<xsl:value-of select="."/>');
</xsl:attribute><xsl:value-of select="."/>
</a>
</TD>
</xsl:when>

<!-- RTV_NO - Test and add hyperlink when it is not empty -->
<xsl:when test="(name()='RTV_NO') and not(node()='')">
<TD BGCOLOR="White" STYLE="height: 8px; FONT-SIZE: 8pt;" WIDTH="1%">
<a href="javascript: void(0);">
<xsl:attribute name="onclick">fnViewRTV('<xsl:value-of select="."/>');
</xsl:attribute><xsl:value-of select="."/>
</a>
</TD>
</xsl:when>

<!-- TKT_NO - Test and add hyperlink when it is not empty -->
<xsl:when test="(name()='TKT_NO') and not(node()='')">
<TD BGCOLOR="White" STYLE="height: 8px; FONT-SIZE: 8pt;" WIDTH="1%">
<a href="javascript: void(0);">
<xsl:attribute name="onclick">fnViewTicket('<xsl:value-of select="."/>');
</xsl:attribute><xsl:value-of select="."/>
</a>
</TD>
</xsl:when>

<!-- VEND_NO - Test and add hyperlink when it is not empty -->
<xsl:when test="(name()='VEND_NO' or name()='ITEM_VEND_NO') and not(node()='')">
<TD BGCOLOR="White" STYLE="height: 8px; FONT-SIZE: 8pt;" WIDTH="1%">
<a href="javascript: void(0);">
<xsl:attribute name="onclick">fnViewVendor('<xsl:value-of select="."/>');
</xsl:attribute><xsl:value-of select="."/>
</a>
</TD>
</xsl:when>

<!-- Otherwise - Just show the column data -->
<xsl:otherwise>
<TD BGCOLOR="White" STYLE="height: 8px; FONT-SIZE: 8pt;" WIDTH="1%">
<SMALL><xsl:value-of select="."/></SMALL>
</TD>
</xsl:otherwise>

</xsl:choose>
</xsl:for-each>
<!-- build the copy button and tie it to the clipboard-->
<TD WIDTH="1%" BGCOLOR="White">

<script type="text/javascript">
function ClipBoard(holdtext, copytext)
{
holdtext.innerText=copytext.innerText;
Copied=holdtext.createTextRange();
Copied.execCommand("Copy");
}
</script>

<SPAN ID="copytext" STYLE="display:none;">
<!-- enter the data to copy below-->
Original service#:<xsl:value-of select="./TKT_NO"/> Original service Date:<xsl:value-of select="./TKT_DAT"/> Original work performed:<xsl:value-of select="./SVC_NOTES_TXT"/>
<!--enter the data to copy above-->
</SPAN>
<TEXTAREA STYLE="display:none;">
</TEXTAREA>
<BUTTON onClick="ClipBoard(previousSibling, parentElement.getElementsByTagName('SPAN')[0]);">copy</BUTTON>


</TD>
</TR>

</xsl:for-each>
</TABLE>

</DIV>
<!-- End Section K and Query 9 processing -->

steamngn
11-25-2005, 01:08 AM
You know, I've been doing some digging into this, and it is really interesting that there are many rtf to xml conversion apps out there, but no scripts or anything that does something similar:( . All of these apps are written with the idea of converting an entire document to xml (makes sense; there are many needs for this, and an app would be neede rather than a simple script), but I believe that a simple script to at least convert most RTF to xml would be popular indeed. There are many examples of RTF text boxes for web pages, and the text inputted there is most likely stored in some sort of database column as a string. What about being able to display that text later in a web page WITHOUT having any RTF control present, ie just the text on a page with the RTF formatting?
Andy