Altova Mailing List Archives


Re: [xsl] Trouble getting Google AJAXSLT to process & for output

From: "bryan rasmussen" <rasmussen.bryan@--------->
To:
Date: 5/21/2007 1:24:00 PM
well, I thought AJAXSLT was a javascript implementation of XSLT that
first checks to see if it can create an object to do an XSLT transform
before it goes to the javascript implementation. Something like that.

If I remember correctly on this I think it would work pretty poorly
for anything major, but then I've never felt the slightest inclination
to try it out.
Also I don't remember reading that it was a 2.0 implementation at all.
In fact if it were, that would be pretty amazing. an order of
magnitude more amazing than just an XSLT implementation I think.

Try Sarissa for a cross-platform javascript XML solution, does not
implement XSLT, but allows you to use the XSLT implementations on
browsers in a compatible way.


Cheers,
Bryan Rasmussen





On 5/21/07, Bob Hughes <bob@xxxxxxxxxxxxx> wrote:
Hello,



I'm using the Google AJAXSLT version 0.7 library, XSLT version 2.0.



I'm trying to off load a server by doing the XSL processing on the
client side.  Our application is simply taking XML data and converting
it to an HTML table by embedding the XML data and XSL style sheet into
an HTML page and using the Google libraries with javascript in order to
do the transformation.  The problem is that any cells containing '&' in
the &amp; form do not get output the HTML table cell.  I have tried many
forms of "&" and using disable-output-escaping to no avail.

Anybody out there familiar with doing this Google's AJAXSLT libraries.
Are there any other client side XSLT libraries out there?

I have included the HTML source page with the embedded data and style
sheet.

Thanks



Bob







<HTML>
  <HEAD>
    <TITLE>Business Group Phone List</TITLE>

    <STYLE TYPE="text/css">.headerCell
{text-align:center;font-weight:bold; color:white;
background-color:#444444;padding-right:1ex; padding-left:1ex;
height:20pt;} .bodyCell{font-size:10pt; padding-right:1ex;
padding-left:1ex;}</STYLE>


    <script src="../Scripts/xmltoken.js"
type="text/javascript"></script>
    <script src="../Scripts/util.js" type="text/javascript"></script>
    <script src="../Scripts/dom.js" type="text/javascript"></script>
    <script src="../Scripts/xpath.js" type="text/javascript"></script>
    <script src="../Scripts/xslt.js" type="text/javascript"></script>
    <script type="text/javascript">

logging = false;
xsltdebug = false;
xpathdebug = false;

function el(id) {
  return document.getElementById(id);
}

function test_xslt() {
  try {
    var xml = xmlParse(el('xml').value);
    var xslt = xmlParse(el('xslt').value);
    var html = xsltProcess(xml, xslt);
    el('html').value = html;
    el('htmldisplay').innerHTML = html;
  } catch (err)
  {
    alert(err);
  }
}

function cleanxml() {
  cleanvalue('xml');
  cleanvalue('xslt');
}

function cleanvalue(id) {
  var x = el(id);
  x.value = x.value.replace(/^\s*/, '').replace(/\n\s*/g, '\n');
}

</script>
</HEAD>
  <BODY onload="cleanxml();test_xslt()")">
   <table>
    <tr>
      <td><textarea id="xml" cols="40" rows="10"><xml-fragment
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><colHeading>Name</
colHeading><colHeading>Number</colHeading><colHeading>Extension</colHead
ing><colHeading>Mobile</colHeading><colHeading>Email
Address</colHeading><colHeading>Department</colHeading><colHeading>Hirag
ana Name</colHeading><colHeading>Group Id</colHeading><colHeading>Yahoo
Id</colHeading><colHeading>First Name</colHeading><colHeading>Last
Name</colHeading><colHeading>User
Id</colHeading><colHeading>Pager</colHeading><colHeading>Title</colHeadi
ng><colHeading>Time
Zone</colHeading><colHeading>Location</colHeading><colHeading>Address
Line 1</colHeading><colHeading>Address Line
2</colHeading><colHeading>City</colHeading><colHeading>State</colHeading
><colHeading>Zip</colHeading><colHeading>Country</colHeading><row><col>O
'Doe,John</col><col/><col/><col/><col/><col/><col>O'Doe,John</col><col>C
&amp; T
Inc.</col><col/><col>John</col><col>O'Doe</col><col>johndoe</col><col/><
col/><col>America/New_York</col><col/><col/><col/><col/><col/><col/><col
/></row></xml-fragment></textarea></td>

    <td><textarea id="xslt" cols="40" rows="10"><?xml version="1.0"
encoding="ISO-8859-1"?>

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" >
      <xsl:variable
name="BGPL_OCI_SUMMARY_NAME"><xsl:text>Name</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_LOCATION"><xsl:text>Location</xsl:text></xsl:vari
able>
      <xsl:variable
name="BGPL_ROOT_SUMMARY_ENTRY_DEPT"><xsl:text>Dept.</xsl:text></xsl:vari
able>
      <xsl:variable
name="BGPL_OCI_SUMMARY_ADDRESS_LINE_2"><xsl:text>Address Line
2</xsl:text></xsl:variable>
      <xsl:variable name="BGPL_OCI_SUMMARY_FIRST_NAME"><xsl:text>First
Name</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_EMAIL_ADDRESS"><xsl:text>Email
Address</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_ADDRESS_LINE_1"><xsl:text>Address Line
1</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_DETAIL_MOBILE"><xsl:text>Mobile</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_CITY"><xsl:text>City</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_ENTRY_DETAIL_ENTRY_VOICE"><xsl:text>Voice</xsl:text></xsl:var
iable>
      <xsl:variable name="BGPL_OCI_SUMMARY_LAST_NAME"><xsl:text>Last
Name</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_ZIP"><xsl:text>Zip</xsl:text></xsl:variable>
      <xsl:variable
name="findOp0"><xsl:text>STARTS_WITH</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_DETAIL_VOICE"><xsl:text>Voice</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_ROOT_SUMMARY_ENTRY_EXT"><xsl:text>Ext.</xsl:text></xsl:variab
le>
      <xsl:variable
name="BGPL_OCI_SUMMARY_TITLE"><xsl:text>Title</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_EXTENSION"><xsl:text>Extension</xsl:text></xsl:va
riable>
      <xsl:variable name="BGPL_OCI_SUMMARY_YAHOO_ID"><xsl:text>Yahoo
Id</xsl:text></xsl:variable>
      <xsl:variable
name="ENTPL_ROOT_SUMMARY_ENTRY_GROUP"><xsl:text>Group</xsl:text></xsl:va
riable>
      <xsl:variable name="BGPL_OCI_SUMMARY_GROUP_ID"><xsl:text>Group
Id</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_MOBILE"><xsl:text>Mobile</xsl:text></xsl:variable
>
      <xsl:variable
name="name"><xsl:text>TestEnterprise</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_HIRAGANA_NAME"><xsl:text>Hiragana
Name</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_DEPARTMENT"><xsl:text>Department</xsl:text></xsl:
variable>
      <xsl:variable
name="xslURL"><xsl:text>bglist_summary.xsl</xsl:text></xsl:variable>
      <xsl:variable name="BGPL_OCI_SUMMARY_TIME_ZONE"><xsl:text>Time
Zone</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_ROOT_DETAIL_HTML_TITLE"><xsl:text>Business Group Phone
List</xsl:text></xsl:variable>
      <xsl:variable
name="source"><xsl:text>serviceProvider</xsl:text></xsl:variable>
      <xsl:variable
name="locale"><xsl:text>en_US</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_ENTRY_DETAIL_ENTRY_PAGER"><xsl:text>Pager</xsl:text></xsl:var
iable>
      <xsl:variable name="BGPL_ROOT_DETAIL_PAGE_TITLE"><xsl:text>Phone
List</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_HTML_TITLE"><xsl:text>Business Group Phone
List</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_ROOT_SUMMARY_HTML_TITLE"><xsl:text>Business Group Phone
List</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_DETAIL_PAGER"><xsl:text>Pager</xsl:text></xsl:variable>
      <xsl:variable name="BGPL_ROOT_ALERT"><xsl:text>Note: It may take a
few moments for the phone list to appear</xsl:text></xsl:variable>
      <xsl:variable
name="isEnterprise"><xsl:text>true</xsl:text></xsl:variable>
      <xsl:variable name="BGPL_OCI_SUMMARY_PAGE_TITLE"><xsl:text>Phone
List</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_STATE"><xsl:text>State</xsl:text></xsl:variable>
      <xsl:variable name="BGPL_ROOT_SUMMARY_PAGE_TITLE"><xsl:text>Phone
List</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_NUMBER"><xsl:text>Number</xsl:text></xsl:variable
>
      <xsl:variable
name="BGPL_ROOT_SUMMARY_ENTRY_PHONE"><xsl:text>Phone</xsl:text></xsl:var
iable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_PAGER"><xsl:text>Pager</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_ROOT_SUMMARY_ENTRY_MOBILE"><xsl:text>Mobile</xsl:text></xsl:v
ariable>
      <xsl:variable
name="BGPL_ROOT_SUMMARY_ENTRY_NAME"><xsl:text>Name</xsl:text></xsl:varia
ble>
      <xsl:variable
name="findKey0"><xsl:text>UserLastName</xsl:text></xsl:variable>
      <xsl:variable
name="buttonClicked"><xsl:text></xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_ENTRY_DETAIL_ENTRY_MOBILE"><xsl:text>Mobile</xsl:text></xsl:v
ariable>
      <xsl:variable name="BGPL_OCI_DETAIL_HTML_TITLE"><xsl:text>Business
Group Phone List</xsl:text></xsl:variable>
      <xsl:variable
name="encoding"><xsl:text>ISO-8859-1</xsl:text></xsl:variable>
      <xsl:variable name="bgAlert"><xsl:text>Note: It may take a few
moments for the phone list to appear</xsl:text></xsl:variable>
      <xsl:variable name="BGPL_OCI_DETAIL_PAGE_TITLE"><xsl:text>Phone
List</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_ROOT_SUMMARY_ENTRY_EMAIL"><xsl:text>Email</xsl:text></xsl:var
iable>
      <xsl:variable name="BGPL_OCI_SUMMARY_USER_ID"><xsl:text>User
Id</xsl:text></xsl:variable>
      <xsl:variable
name="BGPL_OCI_SUMMARY_COUNTRY"><xsl:text>Country</xsl:text></xsl:variab
le>
      <xsl:variable name="rowNum"><xsl:text>0</xsl:text></xsl:variable>
      <xsl:variable
name="findValue0"><xsl:text></xsl:text></xsl:variable>

      <xsl:template match="/" >
        <xsl:apply-templates />
      </xsl:template>

      <xsl:template name="nbsp">
        <xsl:text disable-output-escaping="yes">&amp;&nbsp;</xsl:text>
      </xsl:template>

      <xsl:template match="xml-fragment">
         <CENTER>
          <H2>
           <xsl:value-of select="$BGPL_OCI_SUMMARY_PAGE_TITLE"/>
          </H2>
          <TABLE border="1" cellspacing="0" border-collapse="collapse">
           <tr>
            <td class='headerCell'><xsl:value-of
select="$BGPL_OCI_SUMMARY_NAME"/></td>
            <td class='headerCell'><xsl:value-of
select="$BGPL_OCI_SUMMARY_NUMBER"/></td>
            <td class='headerCell'><xsl:value-of
select="$BGPL_OCI_SUMMARY_EXTENSION"/></td>
            <td class='headerCell'><xsl:value-of
select="$BGPL_OCI_SUMMARY_MOBILE"/></td>
            <td class='headerCell'><xsl:value-of
select="$BGPL_OCI_SUMMARY_EMAIL_ADDRESS"/></td>
            <xsl:if test="$isEnterprise = 'true'">
              <td class='headerCell'><xsl:value-of
select="$BGPL_OCI_SUMMARY_GROUP_ID"/></td>
            </xsl:if>
            <td class='headerCell'><xsl:value-of
select="$BGPL_OCI_SUMMARY_DEPARTMENT"/></td>
           </tr>
           <xsl:apply-templates select="row"/>
          </TABLE>
          </CENTER>
      </xsl:template>

      <!-- Within each row display only those columns whose column
headers were displayed above -->

      <xsl:template match="row">
      <tr>
       <td>
        <xsl:choose>
         <xsl:when test="string-length(col[10]) ='0'">
           <xsl:value-of select="col[12]" /><xsl:call-template
name="nbsp"/>
         </xsl:when>
         <xsl:otherwise>
           <xsl:value-of select="col[1]" /><xsl:call-template
name="nbsp"/>
         </xsl:otherwise>
        </xsl:choose>
       </td>
       <td>
        <xsl:value-of select="col[2]" /><xsl:call-template name="nbsp"/>
       </td>
       <td>
        <xsl:value-of select="col[3]" /><xsl:call-template name="nbsp"/>
       </td>
       <td>
        <xsl:value-of select="col[4]" /><xsl:call-template name="nbsp"/>
       </td>
       <td>
        <xsl:value-of select="col[5]" /><xsl:call-template name="nbsp"/>
       </td>
       <xsl:if test="$isEnterprise = 'true'">
        <td>
        <xsl:value-of select="col[8]" disable-output-escaping="yes"
/><xsl:call-template name="nbsp"/>
        </td>
       </xsl:if>
       <td>
        <xsl:value-of select="col[6]" /><xsl:call-template name="nbsp"/>
       </td>
      </tr>
     </xsl:template>
   </xsl:stylesheet>
  </textarea></td>

  <td><textarea id="html" cols="40" rows="10"/>abc</textarea></td>
 </tr>
</table>

<div id="htmldisplay"/>
</BODY>
</HTML>

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.