mercredi 17 juin 2015

How are xml namespaces linked to the parser

I am trying to understand the role of namespaces in XML/XHTML files used by Java EE applications (e.g. Facelet views, but the question is more general)

Example (not functional, but containing h, f and no prefixes):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://ift.tt/kkyg93">
<html lang="en"
      xmlns="http://ift.tt/lH0Osb"
      xmlns:h="http://ift.tt/J1LPWj"
      xmlns:f="http://ift.tt/19DXC4H">
<h:head>
        ...
</h:head>
<h:body>
    <h:form>
        <p><h:inputText ...>
               <f:validateLongRange minimum="..."
                                    maximum="..."/>
            </h:inputText>
        </p>
    </h:form>
</h:body>

What I do understand:

  • Namespaces are used to separate the tags of different contexts. So using prefixes you can use the same tag with different meanings.
  • The namespace URI is just an unambiguous identifier, and it is not used by the browser(?) to retrieve any information over the internet.

But at some point the tags have to be interpreted.

What I still do not understand is how Java EE knows, the tags of which namespace are to be interpreted as Java EE tags?

Questions linked to the subject are:
- Which application does the parsing and how is this linked to the concrete namespace?
- What are XSDs and are they used in this case?
- what are tag libraries, where are they stored and when are they loaded / looked up?

I read many websites on this subject. Some questions and answers on tackoverflow go into the right direction, but stay too vague, using words like "can", "should", "often" etc. Some of it I just do not understand
(e.g. How are xml schemas referenced in practice?
http://ift.tt/1Bm3oes)

I would like to know, how it is done in the concrete case of a JSF application using "html" and "core" namespaces (see example).

Aucun commentaire:

Enregistrer un commentaire