Coder Social home page Coder Social logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
The real problem is that the XHTML Parser doesn't recognize XHTML entities

Original comment by [email protected] on 21 Aug 2008 at 5:12

from wikimodel.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Here's how we do it in XWiki land:

        // Parse the XHTML using an XML Parser and Wrap the XML elements in XMLBlock(s).
        // For each XML element's text, run it through the main Parser.

        XMLBlockConverterHandler handler = createContentHandler(parameters);

        try {
            XMLReader xr = XMLReaderFactory.createXMLReader();
            xr.setContentHandler(handler);
            xr.setErrorHandler(handler);
            xr.setEntityResolver(this.entityResolver);

            // Since XML can only have a single root node and since we want to allow
users to put
            // content such as the following, we need to wrap the content in a root node:
            // <tag1>
            // ..
            // </tag1>
            // <tag2>
            // </tag2>
            String normalizedContent =
                "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
                    + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" +
"<root>" + content + "</root>";

            xr.parse(new InputSource(new StringReader(normalizedContent)));
        } catch (Exception e) {
            throw new MacroExecutionException("Failed to parse content as XML [" +
content + "]", e);
        }

Note that we have a special entity resolver so that it works even when internet 
is
off (or simply to speed things) and thus we have the 3 entity files 
(xhtml-lat1.ent,
xhtml-special.ent and xhtml-symbol.ent) + the DTD file (xhtml1-strict.dtd).

Original comment by [email protected] on 22 Aug 2008 at 7:10

from wikimodel.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
See
http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-xml/src/main/java/o
rg/xwiki/xml/LocalEntityResolver.java
for the xwiki entity resolver implementation

Original comment by [email protected] on 22 Aug 2008 at 7:22

from wikimodel.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024

Original comment by [email protected] on 27 Aug 2008 at 1:41

  • Added labels: Priority-Critical
  • Removed labels: Priority-Medium

from wikimodel.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Fixed. This wasn't a problem of entity resolving.

Original comment by [email protected] on 12 Sep 2008 at 7:15

  • Changed state: Fixed

from wikimodel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.