Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 1st, 2009, 04:20 PM
Registered User
 
Join Date: Jul 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Question Using XSLT to tranform XML into JSF

Hi,

I am trying to find a example of using XSLT to transform XML into JSF. I've seen a couple of threads in other forums that indicate that this is easy; however, when I've tried it I've run into problems. Searching the web has yielded no good examples. In particular, I am having trouble with the taglibs. Here's my stylesheet:

Code:
 
<?xml version="1.0"?> 
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:b64="xalan://com.hospira.mms.mmu.core.utility.base64.Base64"
xmlns:dep="xalan://com.hospira.mms.mmu.apps.softwaremanagement.Deployer"
extension-element-prefixes="b64 dep">

<xsl:template match="TAG">
<html>
<xsl:text disable-output-escaping="yes">
&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
&lt;%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
&lt;%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
</xsl:text>
<body>
<img src="../hmss/images/MedNet50.jpg" />
<h:dataTable>
<h:column>
<f:facet name="header">
<h:outputText value="tag id"/>
</f:facet>
<h:outputText value="<xsl:value-of select="tagid"/>"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="mac address"/>
</f:facet>
<h:outputText value="<xsl:value-of select="mac"/>"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="map name"/>
</f:facet>
<h:outputText value="<xsl:value-of select="posmapname"/>"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="timestamp"/>
</f:facet>
<h:outputText value="<xsl:value-of select="postimestamp"/>"/>
</h:column>
</h:dataTable>
<xsl:variable name="data" select="data_b"/>
<xsl:value-of select="b64:decodeToFile($data,'map.png')"/>
<img src="{dep:deployFile('map.png')}" />
</body>
</html>
</xsl:template>

</xsl:stylesheet>
I am using the XALAN processor. My operating system is Windows XP. My problem is strictly with the taglibs. Any help is appreciated.

Regards,
Paul
Reply With Quote
  #2 (permalink)  
Old July 1st, 2009, 07:05 PM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You say you're having trouble but you don't say what trouble you are having.

Producing output in a non-XML format will always be a bit tricky, but it can usually be achieved using disable-output-escaping provided it's supported in your particular environment. This may depend on how you run the transformation, e.g. it may not work when writing to a DOM result.

This code is nonsense:

<h:outputText value="<xsl:value-of select="tagid"/>"/>

because it means your stylesheet isn't even well-formed XML. It should be

<h:outputText value="{tagid"}"/>

This of course is nothing to do with the taglibs.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
pdimilla (July 2nd, 2009)
  #3 (permalink)  
Old July 2nd, 2009, 06:38 PM
Registered User
 
Join Date: Jul 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I just assumed it was taglib problem because I saw the following exception in my app log:

Code:
org.xml.sax.SAXParseException: The prefix "h" for element "h:dataTable" is not bound.        org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)        org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)        org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:920)        org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:774)
I see that the problem goes far beyond that. And, yes, I believe I am writing to a DOM result.

Thank you for your help.
Reply With Quote
  #4 (permalink)  
Old July 3rd, 2009, 03:50 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>The prefix "h" for element "h:dataTable" is not bound.

That's not a taglib problem, it's a basic XML problem. In XSLT, as in XML, you need to declare your namespace prefixes.

Unfortunately I think you're trying to tackle quite a tricky XSLT problem when you haven't learnt enough of the basics to tackle simple problems. I really would recommend reading some good books or tutorials and starting with easier problems. You can't expect to jump in a car and start driving without having some lessons first.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #5 (permalink)  
Old July 3rd, 2009, 03:50 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Oh, and by the way: if you get an error message and don't understand it, then it helps to post the error message.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding xml-html transformation of an xml string using xslt and javascript suprakash444 XSLT 1 January 12th, 2009 01:23 AM
get error while tranform blank xml pradipkumar XSLT 4 November 20th, 2007 01:42 AM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
XSLT for complicated xml to xml transf. required doug@sirvisetti XSLT 3 June 17th, 2005 04:26 PM
Merge XML files into a xml file using xslt lxu XML 4 November 6th, 2003 06:01 PM



All times are GMT -4. The time now is 02:32 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.