xsl-list
[Top] [All Lists]

Still battling with practical strategy for parsing escaped XML inside unescaped XML

2003-07-28 13:37:21
Ok, I'm now convinced that it's not practical to just use 
"disable-output-escaping" to enable parsing of escaped XML data.  It's fine if 
I just need to print it directly, but it does me no good if I need to do more 
with it.

So, I'm now trying to use a small variation of the "taggifier.xsl" script that 
Américo Albuquerque [melinor(_at_)sapo(_dot_)pt] provided in an earlier 
response to me, which just uses string searches and manipulation to produce the 
result.  I've changed the names slightly, and I'm trying to coerce the final 
result on completion.

I'm showing here my simple "data.xml" and "filter.xsl" files, along with the 
output I get from a "xalan" wrapper script.  It appears that I'm still having 
trouble with treefrag vs. nodelist (or nodeset).  Note that my code for 
concatenating the key and the value in the "for-each" very likely doesn't work 
yet, but it doesn't get there yet.

Note that I'm using Xalan 2.5.1 with JDK1.4.1 (I also tried the same test with 
JDK1.3.1).

Is this a possible strategy, or is this just as useless as the "d.o.e" strategy?

------------data.xml---------
<data>
 <other>
  <key>controlInfo</key>
  
<value>&lt;control1&gt;VB&lt;/control1&gt;&lt;control2&gt;FC123&lt;/control2&gt;</value>
 </other>
 <other>
  <key>auditInfo</key>
  
<value>&lt;userid&gt;U999999&lt;/userid&gt;&lt;branchnumber&gt;123&lt;/branchnumber&gt;&lt;loannumber&gt;10000003&lt;/loannumber&gt;</value>
 </other>
</data>
------------data.xml---------

-----filter.xsl---------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:xalan="http://xml.apache.org/xslt";
  extension-element-prefixes="xalan"
  version="1.0">
  <xsl:include href="unescaper.xsl"/>
  <xsl:output method="xml" indent="yes" xalan:indent-amount="2"/>

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

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

  <xsl:template match="other">
    <xsl:variable name="keyValue" select="key"/>
    <xsl:variable name="values">
      <xsl:call-template name="unescape">
        <xsl:with-param name="str" select="value"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:for-each select="$values">
      <xsl:value-of select="$keyValue"/>-<xsl:value-of select="name()"/>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
-----filter.xsl---------

--------shell output------
[;] xalan -IN data.xml -XSL filter.xsl

file:.../filter4.xsl; Line #23; Column #33;  XSLT Error 
(org.apache.xpath.XPathException): Can not convert #RTREEFRAG to a NodeList!
--------shell output------


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>