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

I've been searching over the internet a solution to my problem but I couldn't find any so far. I want to transform a XML file in a JSF page. I've created a XSL file and parsed it using Xalan for Java. The problem is that the file generated by the parser always include a namespace definition inside my component tag, for example, instead of getting as outcome <h:input id="input1"/> I get <h:inputText id="input1" xmlns:h="http://java.sun.com/jsf/html"/>.
I'd like to know how should I proceed to suppress this namespace definition, using Xalan or other API.


Below are my xsl and my generated jsp file:

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
exclude-result-prefixes="f h">

<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>
<h:inputText id="{$id}" />
</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="input1" xmlns:h="http://java.sun.com/jsf/html"/>




Thanks in advance!
Paulo S.
Reply With Quote