p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XSLT
I forgot my password Register Now
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 1st, 2009, 05:20 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 1st, 2009, 08:05 PM
mhkay's Avatar
Wrox Author
Points: 12,642, Level: 48
Points: 12,642, Level: 48 Points: 12,642, Level: 48 Points: 12,642, Level: 48
Activity: 97%
Activity: 97% Activity: 97% Activity: 97%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,900
Thanks: 0
Thanked 80 Times in 78 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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, 07:38 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old July 3rd, 2009, 04:50 AM
mhkay's Avatar
Wrox Author
Points: 12,642, Level: 48
Points: 12,642, Level: 48 Points: 12,642, Level: 48 Points: 12,642, Level: 48
Activity: 97%
Activity: 97% Activity: 97% Activity: 97%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,900
Thanks: 0
Thanked 80 Times in 78 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old July 3rd, 2009, 04:50 AM
mhkay's Avatar
Wrox Author
Points: 12,642, Level: 48
Points: 12,642, Level: 48 Points: 12,642, Level: 48 Points: 12,642, Level: 48
Activity: 97%
Activity: 97% Activity: 97% Activity: 97%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,900
Thanks: 0
Thanked 80 Times in 78 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 02:58 AM
XSLT for complicated xml to xml transf. required doug@sirvisetti XSLT 3 June 17th, 2005 05: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 08:45 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc