XML SyntaxWhy do I keep getting "not well-formed" errors?GXP is an XML language. XML has a concept of "well-formedness". Your file does not comply, hence the problem. XML is much more strict than HTML (and HTML is actually a lot more strict than most people realize -- browsers are very forgiving and will accept a lot of invalid HTML). The most common problems people run into are:
How do I use entities like nbsp?Your document must include a doctype to tell the xml parser about html entities. Try inserting this at the top of your document: <?xml version="1.0" ?> <!DOCTYPE gxp:template SYSTEM "http://gxp.googlecode.com/svn/trunk/resources/xhtml.ent"> What does "unbound prefix" mean?This means that you're using an XML namespace prefix (eg: the "gxp:" in "<gxp:template>") that hasn't been declared. To fix the problem you need to add an xmlns declaration to your <gxp:template> element. For example: <gxp:template name="com.google.foo.Bar"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:call="http://google.com/2001/gxp/call"
xmlns:expr="http://google.com/2001/gxp/expressions"
xmlns:gxp="http://google.com/2001/gxp">See also Namespaces in XML 1.0: Declaring Namespaces. The |
| Value | HTML DOCTYPE | XHTML DOCTYPE | IE Mode | Mozilla Mode |
| strict | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | Standards | Standards |
| transitional | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | Standards | Quirks |
| frameset | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> | <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> | Standards | Quirks |
| mobile | not allowed | <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd> | ||
| attribute not present | N/A | N/A | Quirks | Quirks |
Note that this does not cause your generated code to magically validate against the specified DTD.
Why does it keep escaping the ampersands (&) in my URLs?
This is actually correct behavior. Strictly speaking, HTML with unescaped ampersands in URLs is invalid (and ambiguous). See also Common HTML Validation Problems: Ampersands in URLs.
Escaping Generated Output
Is there any way to prevent <eval> from escaping the value of the expression?
For most types of expressions <gxp:eval> (and expr: attributes) will do the equivalent of a String.valueOf() on the value, and then escape the resulting string. A notable exception is objects of type GxpClosure where the writeHtml method is called and no escaping is performed.
If you are suffering from excess escaping you can either create an implementation of the appropriate GxpClosure interface, or instantiate one of the implementations included as part of the runtime library.
How do get around having to escape characters when I write Javascript inside of a gxp file?
Illegal XML characters must be escaped inside a gxp file. This means < > " ' and & all have to be escaped. Escaping these characters makes javascript hard to read; not escaping these characters renders the gxp file not compilable. One solution to this problem is to use CDATA to enclose the javascript. The XML parser will ignore everything enclosed by the CDATA tag. See the XML Specification for more information.
Here's the syntax for using CDATA:
<script type="text/javascript">
<![CDATA[
function foo() {
}
]]>
</script>Note that:
- Any gxp tag is ignored inside the CDATA block. This includes gxp:msg tags. So if you have strings that need to be translated, don't put them inside CDATA.
- You can't use CDATA if your block contains <![CDATA[ or ]]>
Error: "java.lang.UnsupportedClassVersionError?: Bad version number in .class file" when executing com.google.gxp.compiler.cli.Gxpc.
My Java version is : java version "1.5.0_15" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_15-b04) Java HotSpot?(TM) 64-Bit Server VM (build 1.5.0_15-b04, mixed mode)
quick compare to freemarker and jstl would be highly appreciated!