Thread: XML to JSF
View Single Post
  #3 (permalink)  
Old October 6th, 2010, 11:44 AM
prss prss is offline
Registered User
 
Join Date: Oct 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I managed to find a solution. I just dropped the namespace declaration in the beginning of the xsl file and I replaced the < signal for &lt;
The problem I have now is that after these modifications the follow expression {$id} doesn't work any more. My generated jsp file contains <h:inputText id="$id" /> instead of <h:inputText id="input1" />
I tried to write the expression <xsl:value-of select="input_text/@id" /> but despite of bringing the correct value (input1) it breaks the line resulting in something like that:
<h:inputText id= />
input1

Can anyone help me to solve this issue?

Follow my files:

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:template match="/">

<xsl:text disable-output-escaping="yes">
&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"%>
&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
</xsl:text>

<xsl:for-each select="questionario/componente">
<br />
<xsl:if test="attribute::nome = 'input'">
<xsl:variable name="label">
<xsl:value-of select="input_text/@label" />
</xsl:variable>
<br />
<xsl:variable name="id">
<xsl:value-of select="input_text/@id" />
</xsl:variable>
<xsl:text disable-output-escaping="yes">
&lt;h:inputText id="$id" /&gt;
</xsl:text>
</xsl:if>
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>


------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<br/><br/>
<h:inputText id="$id" />

Thanks again,
Paulo S.
Reply With Quote