Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 22nd, 2008, 08:34 PM
Authorized User
 
Join Date: May 2007
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Default entity handling with java extensions

We are using a java extension to do some more complicated data manipulation.

However, the return from the java function is using entity references instead of <>:

&lt;tr&gt;&lt;td class="border_left"&gt

Where as I want:

<tr><td class="border_left">

Any help is greatly appreciated.

The XSL is:

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:parse="java:ViewEnergyBid"
xmlns:saxon="http://icl.com/saxon"
extension-element-prefixes="saxon">


<xsl:output method="html" encoding="UTF-8" indent="no" saxon:character-representation="native;native"/>



<xsl:template match="/">
<xsl:variable name="input">
<xsl:copy-of select="//Curve"/>
</xsl:variable>


<html>
<head/>
<body>
<table>

<xsl:value-of select="parse:buildAndParseNodeset($input) "/>

</table>
</body>
</html>

</xsl:template>

</xsl:stylesheet>
 
Old January 23rd, 2008, 05:21 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

What is the return value of your Java function?

If it is "String" then that is the problem. Change it to NodeSet (or whatever the correct type is) and return the XML as an object, not as its string representation.

/- Sam Judson : Wrox Technical Editor -/
 
Old January 23rd, 2008, 05:31 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I think the Java method must have returned unparsed lexical XML - if it had returned a node, then the xsl:value-of would have flattened the node, and the markup would have disappeared entirely rather than being escaped. So I suspect two changes are needed: (a) return a tree of nodes rather than lexical XML, and (b) use xsl:copy-of rather than xsl:value-of.

But I always wonder with this sort of thing whether escaping into Java is really needed anyway. A lot of people do it because they haven't yet learned what can be achieved in XSLT without extensions.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Some Extensions plb BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 July 29th, 2008 11:57 AM
Jumping into java extensions to Saxon mphare XSLT 2 April 29th, 2008 10:02 PM
character entity into numeric character entity srkumar XSLT 1 November 22nd, 2007 04:53 AM
Difference between Entity and Entity type arshad mahmood C++ Programming 0 May 8th, 2004 12:34 AM
File Extensions nbnelson C# 2 August 25th, 2003 12:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.