[jsr-314-open-mirror] [jsr-314-open] [490-XmlViews] Chapter 11: The JSF XML View Syntax

Andy Schwartz andy.schwartz at oracle.com
Tue Oct 26 13:15:18 EDT 2010


On 10/25/10 7:57 PM, Cay Horstmann wrote:
> Thanks Blake for explaining it so well. That's exactly right.
>
> A user could actually nominate http://java.sun.com/jsf/html as the
> namespace without a prefix and prefix the html tags--don't know if
> that's attractive to anyone.
>   

Definitely.  I always assumed that this was common practice.  The 
original Facelets samples that Jacob provided in his documentation, eg:

https://facelets.dev.java.net/nonav/docs/dev/docbook.html#gettingstarted-view-guess

Follow this form.

This is also commonly used throughout the Mojarra demos.

> As for the comments, it is surprising to users that they can't comment
> out parts of pages during debugging--they still get interpreted by
> facelets. You and I know that they can use
> javax.faces.FACELETS_SKIP_COMMENTS or ui:remove, but still, an XML
> author does not expect to have to do such a thing.
>   

Fortunately this confusion will be a thing of the past for folks who use 
the new XML-style Facelets documents.

BTW, regarding Ed's earlier comment:
> EB> the most important manifestation of that, in my opinion, is the
> EB> requirement to have *all* elements prefixed.  For example, a 
> proper JSF
> EB> XML Syntax View would look like this.
> EB>
> EB> <?xml version="1.0" encoding="UTF-8"?>
> EB> <weNeedSomeRootElement
> EB>    xmlns:html="http://www.w3.org/1999/xhtml"
> EB>    xmlns:h="http://java.sun.com/jsf/html">
>

We already have several potential elements/tags that can serve as the 
root level element, including eg:

- <html>
- <h:html>
- <f:view>

As such I don't believe that we need to add yet another element.

This got me to thinking though...  I believe that we have a fairly big 
gap in our XML strategy: I don't see any straightforward way to specify  
a doctypte that will be passed through to the browser.  Earlier Dan had 
suggested adding new elements for this purpose:

> 3) All markup declarations should be produced by the component tree 
> (e.g., XML declaration, doctype, namespaces, CDATA, XML comments, etc)
> This means we need the following tags:
> f:document
> f:doctype
> f:comment (why not, it is just xml)
> f:cdata
> (The prefix is debatable, I'm just throwing it out there)

We have added an h:html component in 2.1 - but as far as I can see we 
haven't addressed the other items.  I think that we minimally need some 
way to specify the doctype - eg. an h:doctype element since without this 
the documents rendered in our XML processing mode will be doctype-less.

BTW, one thing that I am not totally clear on... What value does 
<h:html> add over plain old <html>?

Andy

> On Tue, Oct 26, 2010 at 1:55 AM, Blake Sullivan
> <blake.sullivan at oracle.com> wrote:
>   
>> Ed,
>>
>> I read this the same way as you did originally, but Cay actually wrote
>>
>> CH> 2) To not surprise developers with nonstandard XML processing (such as
>> CH> processing comments).
>>
>> [Emphasis mine]
>>
>> So I think that Cay is either talking about the general issue of comments
>> being passed through, especially since he has his <!-- Comments consumed -->
>> example.
>>
>> I also suspect that instead of saying "*all* elements prefixed", he really
>> means that all generated DOM elements have a valid namespace either through
>> prefixing or through the page author specifying default namespaces:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <weNeedSomeRootElement
>>    xmlns= "http://www.w3.org/1999/xhtml"
>>    xmlns:h="http://java.sun.com/jsf/html"
>>     
>>     <h:html>
>>         <h:head><h:title>Raw XML View</h:title></h:head>
>>     <h:body>
>> <h2>XML declaration: consumed<h2>
>> <h2>Processing instruction: consumed<h2>
>> <?xml-stylesheet href="funky.xsl" type="text/xml" alternate="yes"?>
>> <h2>CDATA section: consumed<h2>
>> <![CDATA[ <p>This is CDATA</p> ]]>
>> <h2>Comments: consumed<h2>
>> <!-- comments consumed -->
>>             <h:form prependId="false" id="form">
>>                 <h:panelGrid id="grid" column="2">
>>                   <h:outputText id="text" value="hello" />
>>                   <h:commandButton id="button" value="reload" />
>>                 </h:panelGrid>
>>                 <p>html template text</p>
>>             </h:form>
>>         </h:body>
>> </h:html>
>> </weNeedSomeRootElement>
>>
>> One of the other aspects shown in Cay's example is that the xml-stylesheet
>> processing instruction would be consumed by the Facelets engine, NOT the
>> browser.
>>
>> -- Blake Sullivan
>>
>>
>> On 10/22/10 8:02 AM, Ed Burns wrote:
>>
>> On Fri, 22 Oct 2010 09:23:33 +0700, Cay Horstmann <cay.horstmann at gmail.com>
>> said:
>>
>> CH> As I had understood it, the need for XML was motivated by these
>> usecases:
>> CH> 1) To allow developers to use standard XML processing tools. In
>> CH> particular, this requires to be truthful about the nature of the
>> CH> documents (i.e. not claim that something is an XHTML file when it
>> CH> isn't, but is really an artifact that will eventually be transformed
>> CH> into XHTML)
>>
>> ...and the most important manifestation of that, in my opinion, is the
>> requirement to have *all* elements prefixed.  For example, a proper JSF
>> XML Syntax View would look like this.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <weNeedSomeRootElement
>>    xmlns:html="http://www.w3.org/1999/xhtml"
>>    xmlns:h="http://java.sun.com/jsf/html">
>>     <h:html>
>>         <h:head><h:title>Raw XML View</h:title></h:head>
>>     <h:body>
>> <html:h2>XML declaration: consumed</html:h2>
>> <html:h2>Processing instruction: consumed</html:h2>
>> <?xml-stylesheet href="funky.xsl" type="text/xml" alternate="yes"?>
>> <html:h2>CDATA section: consumed</html:h2>
>> <![CDATA[ <p>This is CDATA</p> ]]>
>> <html:h2>Comments: consumed</html:h2>
>> <!-- comments consumed -->
>>             <h:form prependId="false" id="form">
>>                 <h:panelGrid id="grid" column="2">
>>                   <h:outputText id="text" value="hello" />
>>                   <h:commandButton id="button" value="reload" />
>>                 </h:panelGrid>
>>                 <html:p>html template text</html:p>
>>             </h:form>
>>         </h:body>
>> </h:html>
>> </weNeedSomeRootElement>
>>
>> CH> 2) To not surprise developers with nonstandard XML processing (such as
>> CH> processing comments).
>>
>> I'm not sure what you mean here.  XML processing instructions are
>> standard in XML.
>>
>>
>>
>>     




More information about the jsr-314-open-mirror mailing list