xsl-list
[Top] [All Lists]

RE: question regd. xsl translation...

2003-07-03 02:08:04
Date: Wed, 2 Jul 2003 21:47:25 +0100
From: "Michael Kay" <mhk(_at_)mhk(_dot_)me(_dot_)uk>
Subject: RE: [xsl] question regd. xsl translation...

I suspect this problem is at the JSP level.

Data written as &lt;xxxx&gt; is not going to work in a stylesheet that
specifies <xsl:template match="xxxx" unless it is double-parsed - one
parse to turn the &lt; character into a < character, and a second parse
to recognize the < as markup indicating an element node.

So you need to tell us more about where the XML document comes from and
how it is processed.

Hello Michael/Others,

 Thanks for your response. the xml document is generated thru java logging
 APIs which convert anything under message tag to entity references.
 so the xml logfile would have

 <message>&lt;xxxx&gt; my message here &lt;/xxxx&gt;</message>

 when i try to log the string "<xxxx> my message here </xxxx>".

 following is the jsp logic: (this is written by someone else
 so, i'm unable to get full picture of how the xml can get parsed twice)
 above xml logfile is fetched and a StreamSource is created,
 and a new transformer object is created with xsl StreamSource as
 an argument. then the transform method is called with the xml
 StreamSource object and "out" object gets the result.

your doubt that xml getting parsed twice is probably right because
if i try to print a message "ethernet/0 <--> 1.2.3.4" the xml file
looks like "<message>&lt;xxxx&gt; ethernet/0 &lt;--&gt; 1.2.3.4 &lt;/xxxx&gt;</message> and nothing appears on the output.

the whole reason i'm trying to introduce element <xxxx> is to take
whatever is under them to be passed under <pre> tags.

i'm still confused about how the templates are not matched
when <message><xxxx> 1.2.3 </xxxx><message> is passed even
if the xml is parsed twice ?

is there a way to verify the xml is getting parsed twice ?
any suggestions to how do i go about solving this problem ?

thanx in advance..
//rick

PS: i've left the original message intact for reference.

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com [mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of xsl user
Sent: 02 July 2003 17:40
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] question regd. xsl translation...



Hi All,

  I'm new to the mailing list and I'm facing problems with the
  html generation using xsl. following is the snippet of the xsl
  template that behaves differently under different translators:

   <xsl:template match="xxxx">
     <xsl:element name="pre">
       <xsl:variable name="report" select="."/>
       <xsl:value-of select="$report"/>
     </xsl:element>
   </xsl:template>

Following is the snippet of the data that works with saxon
and generates the right html.

   <message><xxxx>
       1.    isctmp1
       1.1.    FastEthernet1/0/0  ---  10.2.2.161
       1.2.    FastEthernet3/1/1  ---  10.2.3.97
       6.22.    FastEthernet1/1  ---  10.2.3.86
   </xxxx></message>

but the jsp page i'm trying to modify uses jdk packages for
xsl translation and it does not generate the html when i
pass the above data, but when the following data is passed
it processes the templates and generates the html right.

data-set-that-works-with-jdk

   <message>&lt;xxxx&gt;
       1.    isctmp1
       1.1.    FastEthernet1/0/0  ---  10.2.2.161
       1.2.    FastEthernet3/1/1  ---  10.2.3.97
       6.22.    FastEthernet1/1  ---  10.2.3.86
   &lt;/xxxx&gt;</message>

I think saxon is doing the right thing as i remember
reading from your FAQ that entity references are for
parser's convenience only, and they are not xml elements.

Could you experts clarify it for me please ?

Also, which component is the source of the above behavior ?
is it SAX parser or xslt processor ?

Is anyone aware of a workaround i could use to fix the problem without having to use a different processor like saxon ? (the jsp page is pat of a common component that affects many)

the jsp page uses the jdk 1.4 packages:

org.xml.sax.*
javax.xml.transform.TransformerFactory
javax.xml.transform.Transformer
javax.xml.transform.Source javax.xml.transform.stream.StreamSource
javax.xml.transform.stream.StreamResult

Thanks in advance. I appreciate your help.

//rick



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



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