Revision: 6219 Author: rj...@google.com Date: Fri Sep 25 13:56:23 2009 Log: Changes served location of UiBinder's xhtml.ent from svn to downloads
Also makes match more stringent, and fixes vaccuous test case Review: jgw, jlabanca http://code.google.com/p/google-web-toolkit/source/detail?r=6219 Modified: /trunk/user/src/com/google/gwt/uibinder/rebind/GwtResourceEntityResolver.java /trunk/user/src/com/google/gwt/uibinder/resources/xhtml.ent /trunk/user/src/com/google/gwt/uibinder/sample/client/WidgetBasedUi.ui.xml /trunk/user/test/com/google/gwt/uibinder/rebind/GwtResourceEntityResolverTest.java ======================================= --- /trunk/user/src/com/google/gwt/uibinder/rebind/GwtResourceEntityResolver.java Wed Aug 5 20:27:52 2009 +++ /trunk/user/src/com/google/gwt/uibinder/rebind/GwtResourceEntityResolver.java Fri Sep 25 13:56:23 2009 @@ -1,12 +1,12 @@ /* * Copyright 2009 Google Inc. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -25,13 +25,13 @@ /** * Does special handling of external entities encountered by sax xml parser, * e.g. the uri in - * + * * <pre> - * <!DOCTYPE gwt:UiBinder - SYSTEM "http://google-web-toolkit.googlecode.com/svn/resources/xhtml.ent"></pre> + * <!DOCTYPE gwt:UiBinder + SYSTEM "http://google-web-toolkit.googlecode.com/files/xhtml.ent"></pre> * <p> * Specifically, if the requested uri starts with - * <code>http://google-web-toolkit.googlecode.com/svn/resources</code>, provide + * <code>http://google-web-toolkit.googlecode.com/files</code>, provide * the contents from a built in resource rather than allowing sax to make a * network request. */ @@ -40,9 +40,9 @@ InputStream fetch(String name); } - private static final String EXTERNAL_ENTITY_PREFIX = "http://google-web-toolkit.googlecode.com/svn/resources"; - - private static final String RESOURCES = "com/google/gwt/uibinder/resources"; + private static final String EXTERNAL_ENTITY_PREFIX = "http://google-web-toolkit.googlecode.com/files/"; + + private static final String RESOURCES = "com/google/gwt/uibinder/resources/"; private final ResourceLoader resourceLoader; ======================================= --- /trunk/user/src/com/google/gwt/uibinder/resources/xhtml.ent Wed Aug 5 20:27:52 2009 +++ /trunk/user/src/com/google/gwt/uibinder/resources/xhtml.ent Fri Sep 25 13:56:23 2009 @@ -6,12 +6,22 @@ --> <!-- - This is the complete set of named character entites defined in XHTML1.0. It's - essentially a union of: + This is the complete set of named character entites defined in + XHTML1.0. Though this file was created for the convenience of users + of the Google Web Toolkit, it should be useful for any XML + document. It's essentially a union of: http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent + + Sample usage: + <!DOCTYPE ui:UiBinder + SYSTEM "http://google-web-toolkit.googlecode.com/files/xhtml.ent"> + + This file is maintained at + <http://google-web-toolkit.googlecode.com/svn/trunk/user/src/com/google/gwt/uibinder/resources/xhtml.ent>. Changes + made to it must be propagated to the URL in the sample above. --> <!-- Latin-1 characters --> @@ -208,7 +218,7 @@ existing ISO 8879 entity names. ISO 10646 character numbers are given for each character, in hex. values are decimal conversions of the ISO 10646 values and refer to the document - character set. Names are Unicode names. + character set. Names are Unicode names. --> <!-- C0 Controls and Basic Latin --> @@ -394,7 +404,7 @@ <!ENTITY uArr "⇑"> <!-- upwards double arrow, U+21D1 ISOamsa --> <!ENTITY rArr "⇒"> <!-- rightwards double arrow, U+21D2 ISOtech --> - <!-- Unicode does not say this is the 'implies' character but does not have + <!-- Unicode does not say this is the 'implies' character but does not have another character with this function so rArr can be used for 'implies' as ISOtech suggests --> <!ENTITY dArr "⇓"> <!-- downwards double arrow, U+21D3 ISOamsa --> @@ -467,11 +477,11 @@ <!ENTITY rfloor "⌋"> <!-- right floor, U+230B ISOamsc --> <!ENTITY lang "〈"> <!-- left-pointing angle bracket = bra, U+2329 ISOtech --> - <!-- lang is NOT the same character as U+003C 'less than sign' + <!-- lang is NOT the same character as U+003C 'less than sign' or U+2039 'single left-pointing angle quotation mark' --> <!ENTITY rang "〉"> <!-- right-pointing angle bracket = ket, U+232A ISOtech --> - <!-- rang is NOT the same character as U+003E 'greater than sign' + <!-- rang is NOT the same character as U+003E 'greater than sign' or U+203A 'single right-pointing angle quotation mark' --> <!-- Geometric Shapes --> ======================================= --- /trunk/user/src/com/google/gwt/uibinder/sample/client/WidgetBasedUi.ui.xml Tue Sep 22 11:05:07 2009 +++ /trunk/user/src/com/google/gwt/uibinder/sample/client/WidgetBasedUi.ui.xml Fri Sep 25 13:56:23 2009 @@ -14,7 +14,7 @@ --> <!DOCTYPE ui:UiBinder - SYSTEM "http://google-web-toolkit.googlecode.com/svn/resources/xhtml.ent" + SYSTEM "http://google-web-toolkit.googlecode.com/files/xhtml.ent" [ <!ENTITY % MyEntities SYSTEM "MyEntities.ent"> %MyEntities; @@ -26,13 +26,15 @@ First, this bit: - SYSTEM "http://google-web-toolkit.googlecode.com/svn/trunk/resources/xhtml.ent" + SYSTEM "http://google-web-toolkit.googlecode.com/files/xhtml.ent" allows you to use familiar HTML entities like %nbsp; and •, which are not part of XML. - Next, the bit in square brackets pulls in additional definitions for - &point-left; and &point-right; from local file MyEntities.ent. + Next, the bit in square brackets is even more optional. It shows how + to add your own entities, in this case pulling in additional + definitions for &point-left; and &point-right; from local file + MyEntities.ent. You don't have to be so verbose to include a local file! For example, you might instead grab your own copy of xhtml.ent ======================================= --- /trunk/user/test/com/google/gwt/uibinder/rebind/GwtResourceEntityResolverTest.java Wed Aug 5 20:27:52 2009 +++ /trunk/user/test/com/google/gwt/uibinder/rebind/GwtResourceEntityResolverTest.java Fri Sep 25 13:56:23 2009 @@ -27,7 +27,8 @@ * Text of GwtResourceEntityResolver. */ public class GwtResourceEntityResolverTest extends TestCase { - + private static final String SYSTEM_ID = "http://google-web-toolkit.googlecode.com/files/xhtml.ent"; + private static class MockResourceLoader implements GwtResourceEntityResolver.ResourceLoader { String fetched; @@ -37,7 +38,7 @@ return stream; } } - + private GwtResourceEntityResolver resolver; private MockResourceLoader loader; @@ -46,27 +47,31 @@ super.setUp(); loader = new MockResourceLoader(); resolver = new GwtResourceEntityResolver(loader); + + loader.stream = new InputStream() { + @Override + public int read() throws IOException { + throw new UnsupportedOperationException(); + } + }; } public void testNotOurProblem() throws SAXException, IOException { assertNull(resolver.resolveEntity(null, "http://arbitrary")); assertNull(resolver.resolveEntity("meaningless", "http://arbitrary")); assertNull(resolver.resolveEntity(null, "arbitrary/relative")); + + String almostCorrectAndOnceWorked = SYSTEM_ID.replace("files", "filesss"); + assertNull(resolver.resolveEntity("meaningless", almostCorrectAndOnceWorked)); + assertNull(resolver.resolveEntity(null, almostCorrectAndOnceWorked)); } public void testOursGood() throws SAXException, IOException { String publicId = "some old public thing"; - String systemId = "http://google-web-toolkit.googlecode.com/svn/resources/xhtml.ent"; - loader.stream = new InputStream() { - @Override - public int read() throws IOException { - throw new UnsupportedOperationException(); - } - }; - - InputSource s = resolver.resolveEntity(publicId, systemId); + + InputSource s = resolver.resolveEntity(publicId, SYSTEM_ID); assertEquals(publicId, s.getPublicId()); - assertEquals(systemId, s.getSystemId()); + assertEquals(SYSTEM_ID, s.getSystemId()); assertEquals(loader.stream, s.getByteStream()); } } --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---