Re: [dom4j-user] w3c dtd

2008-01-11 Thread Edwin Dankert
> Right now I've just hosted the dtd stuff locally.

Change the systemId to point to a local version is probably the
simplest solution.

Kind regards,
Edwin
-- 
http://www.edankert.com/

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
dom4j-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-user


Re: [dom4j-user] w3c dtd

2008-01-11 Thread Evan Kirkconnell




Thanks Edwin,
I may give that a whirl at some point.  Right now I've just hosted the
dtd stuff locally.  Not sure if this is frowned upon, but it seems like
it makes more sense than going out to w3 for every single request we
get.
--Evan

Edwin Dankert wrote:

  
For some reason our server is having errors connecting to w3c.org, and
this is causing my dom4j apps to break.  I'd like to turn off validation
and not parse an external DTD

  
  
You could provide your own entity resolver:
http://java.sun.com/j2se/1.5.0/docs/api/org/xml/sax/EntityResolver.html

You can use the entity resolver to point to a local copy of the DTD, or
a subset of this DTD to resolve the entity references.

  
  
but I also need to have the   entity in my xhtml.  My coworker was
saying that he had to use numeric entities, like   for   to be
able to use DOM without a DTD.(he's not using dom4j though)

  
  
Either use character references or declare the entities using an internal DTD
subset.

  
  
I don't know if it's xerces or dom4j, but somehow it ends up with a ?
instead of a non-breaking space when I serialize the document

  
  
The problem is with the underlying XML parser (dom4j does not know anything
about entity references). When an entity reference can not be resolved, the
parser might replace it with a '?' character.

http://www.w3.org/TR/REC-xml/#wf-entdeclared

Kind regards,
Edwin
  





-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace___
dom4j-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-user


Re: [dom4j-user] w3c dtd

2008-01-11 Thread Edwin Dankert
> For some reason our server is having errors connecting to w3c.org, and
> this is causing my dom4j apps to break.  I'd like to turn off validation
> and not parse an external DTD

You could provide your own entity resolver:
http://java.sun.com/j2se/1.5.0/docs/api/org/xml/sax/EntityResolver.html

You can use the entity resolver to point to a local copy of the DTD, or
a subset of this DTD to resolve the entity references.

> but I also need to have the   entity in my xhtml.  My coworker was
> saying that he had to use numeric entities, like   for   to be
> able to use DOM without a DTD.(he's not using dom4j though)

Either use character references or declare the entities using an internal DTD
subset.

> I don't know if it's xerces or dom4j, but somehow it ends up with a ?
> instead of a non-breaking space when I serialize the document

The problem is with the underlying XML parser (dom4j does not know anything
about entity references). When an entity reference can not be resolved, the
parser might replace it with a '?' character.

http://www.w3.org/TR/REC-xml/#wf-entdeclared

Kind regards,
Edwin
-- 
http://www.edankert.com/

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
dom4j-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-user


Re: [dom4j-user] w3c dtd

2008-01-09 Thread Evan Kirkconnell
Oops, w3.org, not w3c.

Evan Kirkconnell wrote:
> For some reason our server is having errors connecting to w3c.org, and 
> this is causing my dom4j apps to break.  I'd like to turn off validation 
> and not parse an external DTD, but I also need to have the   entity 
> in my xhtml.  My coworker was saying that he had to use numeric 
> entities, like   for   to be able to use DOM without a 
> DTD.(he's not using dom4j though)  I was trying to use xerces and have 
> the following code:
> public static SAXReader getSAXReader() throws Exception{   
> SAXParserFactory factory = SAXParserFactory.newInstance();
> factory.setNamespaceAware(false);   
> XMLReader xmlReader = factory.newSAXParser().getXMLReader();
>
> SAXReader saxReader = new SAXReader();   
> saxReader.setXMLReader(xmlReader);
> //saxReader.setFeature("http://xml.org/sax/features/namespaces";, 
> false);
> 
> //saxReader.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar";,
>  
> false);
> 
> saxReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd";,
>  
> false);
> 
> //saxReader.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace";,
>  
> false);   
> saxReader.setValidation(false);
> saxReader.setEntityResolver(null);
> saxReader.setDocumentFactory( df() );
> saxReader.setStripWhitespaceText(true);
>
> return saxReader;
> }
>
> I don't know if it's xerces or dom4j, but somehow it ends up with a ? 
> instead of a non-breaking space when I serialize the document with this 
> code:
>
> OutputFormat of = OutputFormat.createPrettyPrint();
> of.setIndent("\t");   
> of.setLineSeparator("\n");
> //of.setTrimText(trim);
> of.setExpandEmptyElements(false);   
> //of.setNewlines(true);
> //of.setNewLineAfterNTags(1);
> //of.setXHTML(true);
>
> //StringBufferWriter sbw = new StringBufferWriter();   
>
> XMLWriter writer = new EscapedXMLWriter(pw, of);
> writer.setEscapeText(false);
> writer.setResolveEntityRefs(false);
> writer.write(node);
> pw.flush();
>
> Any suggestions are much appreciated.
> --Evan
>
>
> -
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> ___
> dom4j-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>   


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
dom4j-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-user