What do you call "xmlns:p="http://primefaces.org/ui"" - xhtml

What do you call "xmlns:p="http://primefaces.org/ui", are they tags?
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">

It's an XML namespace alias. It introduces p as a shorthand for the namespace http://primefaces.org/ui so that from then on:
<p:moose>
serves as a shorthand for
<moose xmlns="http://primefaces.org/ui">

They are attributes, the purpose of which is to import XML namespaces.
html is the tag.

Related

How do you add an attribute to the html tag in SharePoint masterpages?

I want to turn the following tag produced in SharePoint 2013 master pages:
<html dir="ltr" lang="en-US">
into the following:
<html dir="ltr" lang="en-US" **xml:lang=”en”**>
It is controlled by the following:
<SharePoint:SPHtmlTag dir="<%$Resources:wss,multipages_direction_dir_value%>"
ID="SPHtmlTag"
runat="server" >
I think you are out of luck as that control and the asp.net Control superclasses don't appear to give you an option to set/generate the xml:lang attribute. You could convert:
<SharePoint:SPHtmlTag dir="<%$Resources:wss,multipages_direction_dir_value%>"
ID="SPHtmlTag"
runat="server" >
to something like:
<html ID="SPHtmlTag" runat="server" xml:lang="en" dir="ltr" >
but you'd be missing out on anything else that control was doing for you.

Configure Eclipse to resolve css classes declared in a facelets template

Is there a way to do that? I mean, I want to declare some css classes (either by using style tag or importing a .css resource) and be able to see those imported classes when using autocomplete in a templated view. i.e:
/resources/css/style.css:
.class1{ display: none; }
/views/template.xhtml:
(...)
<head>
<h:outputStylesheet library="css" name="style.css" />
</head>
(...)
view.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
template="/views/template.xhtml">
(...)
<h:outputText value="HiddenValue" styleClass="<CTRL+SPACE should show class1>"/>
(...)
</ui:composition>
JBoss Tools is capable of this (and many more).
How to install it is detailed in this answer.

What's the best way to add a CSS file to the XHTML page

Option 1 <?xml-stylesheet?>
<?xml-stylesheet href="style.css" type="text/css"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Title</title>
</head>
<body></body>
</html>
Option 2 <link/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body></body>
</html>
Both works. Just wondering which is better.
Thanks.
<link> is more cross-browser compatible. Having anything before the DOCTYPE declaration tends to lead to unexpected results, especially in older browsers.
Furthermore, <?xml-stylesheet?> is designed for XML. Unless you're sure your XHTML page is being served in XML mode you should avoid it anyway.
Second option is more comfortable to use still if you have to link more than one stylesheet then you would like to add <link> easily.

Why does £ turn to A using xhtml and css

I have noticed when i put a £ sign in it turns out to be a A when i look at my website in firefox. Do you know the reason why this is happening?
Thanks
it sounds like you've got a page encoded in UTF-8, but being displayed as Latin-1 - make sure the meta tags and/or server headers tell browser what encoding the page uses.
In an XHTML file, you need to declare the encoding in the initial XML tag, and for maximum compatibility, include a meta tag also
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
...
</head>
Bobince suggests in a comment that for maximum backwards compatibility you do something like this
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
...
</head>
If you're curious why you get strange letters, here's the likely explanation...
The pound sign is Unicode character U+00A3
This is encoded in UTF-8 as the two byte sequence C2 A3
if you interpreted that as Latin-1, you'd get ã

Full Example XHTML document showing how to define additional attributes

I am trying to extend an xhtml document to allow extra attributes.
In the w3.org it gives an example like so:
<!ATTLIST a
myattr CDATA #IMPLIED
>
See: 6.1. Defining additional attributes -
http://www.w3.org/TR/1999/xhtml-modularization-19990406/developing.html#s_dev_attrs
However i am not sure where to put that statement.
I have tried adding it like so:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<!ATTLIST a
myattr CDATA #IMPLIED
>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...
</head>
<body>
...
</body>
But when I pick up the doc using DOM that extra DTD statement is ignored.
I have also tried:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
<!ATTLIST a
myattr CDATA #IMPLIED
>
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...
</head>
<body>
...
</body>
But that really caused DOM to throw a wobbly.
So I'd appreciate it if someone could show me a sample xhtml document that has an additional attribute defined. (i.e minimal full doc that could validate)
As you might have guessed....xhtml is not my strong point.
Your second example is correct, apart from the missing </html> end-tag. With that added it parses OK for me. What exactly “throws a wobbly”?
The ATTLIST declaration must indeed go in the DTD, the internal subset of which is within square brackets inside the DOCTYPE declaration.
(What are you hoping to achieve with this? Browsers don't care, even if they are running in native application/xhtml+xml mode. In normal text/html tag soup mode the DTD internal subset will just confuse them.)

Resources