|
|
 |
| 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.
|
 |

July 1st, 2009, 05:20 PM
|
|
Registered User
|
|
Join Date: Jul 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ 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
|

July 1st, 2009, 08:05 PM
|
 |
Wrox Author
Points: 12,642, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,900
Thanks: 0
Thanked 80 Times in 78 Posts
|
|
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
|
|
The Following User Says Thank You to mhkay For This Useful Post:
|
|

July 2nd, 2009, 07:38 PM
|
|
Registered User
|
|
Join Date: Jul 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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.
|

July 3rd, 2009, 04:50 AM
|
 |
Wrox Author
Points: 12,642, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,900
Thanks: 0
Thanked 80 Times in 78 Posts
|
|
>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
|

July 3rd, 2009, 04:50 AM
|
 |
Wrox Author
Points: 12,642, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,900
Thanks: 0
Thanked 80 Times in 78 Posts
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |