Git Product home page Git Product logo

dom4j's Introduction

Maven Central codecov.io Build Status Javadocs

dom4j

dom4j is an open source framework for processing XML which is integrated with XPath and fully supports DOM, SAX, JAXP and the Java platform such as Java 2 Collections.

News

Version 2.1.4 released

See https://github.com/dom4j/dom4j/releases/tag/version-2.1.4

Version 2.0.3 and 2.1.3 released

(Version 2.1.2 has been skipped.)

Improvements

  • Added new factory method org.dom4j.io.SAXReader.createDefault(). It hase more secure defaults than new SAXReader(), which uses system XMLReaderFactory.createXMLReader() or SAXParserFactory.newInstance().newSAXParser(). SAXReader.createDefault() disable parsing of external entities in the SAX parser.

Version 2.1.1 released

Bug fix release.

Potential breaking changes

  • If you use some optional dependency of dom4j (for example Jaxen, xsdlib etc.), you need to specify an explicit dependency on it in your project. They are no longer marked as a mandatory transitive dependency by dom4j.

Fixed issues

  • #28 Possible vulnerability of DocumentHelper.parseText() to XML injection (reported by @s0m30ne)
  • #34 CVS directories left in the source tree (reported by @ebourg)
  • #38 XMLWriter does not escape supplementary unicode characters correctly (reported by @abenkovskii)
  • #39 writer.writeOpen(x) doesn't write namespaces (reported by @borissmidt)
  • #40 concurrency problem with QNameCache (@jbennett2091)
  • #43 and #46 all dependencies are optional (reported by @Zardoz89 and @vmassol)
  • #44 SAXReader: hardcoded namespace features (reported by @philippeu)
  • #48 validate QNames (reported by @mario-areias)

dom4j's People

Contributors

carlosame avatar fauxfaux avatar filipjirsak avatar jayknoxqu avatar jbennett2091 avatar kaffeebaum avatar marianpetras avatar qxo avatar tisoft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dom4j's Issues

XPath – text() should use normalization

Input document can have one element divided into multiple text nodes (text() method than returns multiple nodes). XPath matching than doesn't work - it matches text only with first text node. Text nodes should be normalized before matching XPath.
Input text is divided into multiple text nodes for example when it contains entities - for example < or >.

Validate QName inputs

QName doesn't validate inputs, so it is possible to create QName for example with '<' in the tag name.

The bug was reported by @mario-areias, thanks!

Maven pom.xml is missing the license

Your maven pom.xml is missing the license, like this:

<licenses>
    <license>
      <name>LGPL 2.1</name>
      <url>http://www.gnu.org/licenses/lgpl-2.1.html</url>
      <comments>See discussion at http://whatever.com/license for more details.</comments>
      <distribution>repo</distribution>
    </license>
  </licenses>

XMLWriter removes standalone attribute from XML header

org.dom4j.io.XMLWriter.writeDeclaration() ignores the standalone attribute of the XML header from the input XML. The beautified XML result misses this attribute (even if it was in input XML).

  static String prettyXmlString(final String rawData) throws Exception {
      final Document document = DocumentHelper.parseText(rawData);
      try (StringWriter result = new StringWriter()) {
        final OutputFormat format = OutputFormat.createPrettyPrint();

        final XMLWriter writer = new XMLWriter(result, format);
        writer.write(document);
        writer.close();

        return result.toString();
     }
  }

  public static void main(final String[] args) throws Exception {
    String input = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><elem></elem>";
    System.out.println(prettyXmlString(input));

    input = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?><elem></elem>";
    System.out.println(prettyXmlString(input));
  }

Recursive dependency on jaxen

dom4j requires jaxen for compiling and jaxen requires dom4j for compiling.

This inhibits building both packages from source (read: without basing .jars downloaded elsewhere). Building software from pure source is important to provide a verifiable path from source code to binary, see reproducible builds.

Please remove this dependency-cycle. Thanks.

StringIndexOutOfBoundsException in XMLWriter.writeElementContent()

If the following conditions are met:

  • text-padding format is used – see OutputFormat.setPadText(boolean)
  • the XML document contains a node containing a mixture of text-nodes and other nodes
  • at least one of the mentioned text-nodes is empty

... then method XMLWriter.writeElementContent(Element) may throw a StringIndexOutOfBoundsException.

The cause is that the code assumes that the text of a text-node is never empty. But if the text is empty, then an attempt to get the first character fails with the exception.

A suggested patch is attached.

patch.zip

Can dom4j avoid the Man-in-the-middle attack?

We can use dom4j to get the xml info from a webpage easily. Like we can use next two lines code:
" SAXReader saxReader = new SAXReader();
Document document = saxReader.read("www.google.com");// it is not the right url, just for an example "
But I wonder that can dom4j avoid the Man-in-the-middle attack?
If it can, how? If not, do you have other way to avoid the Man-in-the-middle attack?

looking forward to hearing from you.

Different behavior on IntelliJ and Eclipse

I just need my issue to be answered. I run some project with dependency to dom4j. The short story is it parses some XML that its configuration was defined in some DTD.
It run perfectly on Eclipse. In the other hand, it threw some exception about undefined element on IntelliJ. All of them were exactly same except the IDE. What's the problem here? I still cannot fathom it could happen.

PS: the project also run perfectly on some CI job. I think the problem it's on IntelliJ. But, how can the same library behave differently on the same files?

External DTD crashes

Hey ☺️ I need to parse a document, which contains the following header

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

Which leads to the following stacktrace

Exception in thread "main" org.dom4j.DocumentException: Error on line 31 of document http://www.w3.org/TR/html4/loose.dtd : Deklaration für Entity "HTML.Version" muss mit ">" enden. Nested exception: Deklaration für Entity "HTML.Version" muss mit ">" enden.
	at org.dom4j.io.SAXReader.read(SAXReader.java:482)
	at org.dom4j.io.SAXReader.read(SAXReader.java:264)
	at com.quickbirdstudios.muc.server.parse.BasicParser.parseDetailDetail_html(BasicParser.kt:51)
	at com.quickbirdstudios.muc.server.parse.BasicParser.parseDetails(BasicParser.kt:41)
	at com.quickbirdstudios.muc.server.parse.BasicParser.parseMuscle(BasicParser.kt:24)
	at com.quickbirdstudios.muc.server.parse.BasicParser.parse(BasicParser.kt:17)
	at com.quickbirdstudios.muc.server.MainKt.main(Main.kt:14)
Nested exception: 
org.xml.sax.SAXParseException; systemId: http://www.w3.org/TR/html4/loose.dtd; lineNumber: 31; columnNumber: 3; Deklaration für Entity "HTML.Version" muss mit ">" enden.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472)
	at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanEntityDecl(XMLDTDScannerImpl.java:1604)
	at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDecls(XMLDTDScannerImpl.java:2028)
	at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDTDExternalSubset(XMLDTDScannerImpl.java:306)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1174)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1045)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:959)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at org.dom4j.io.SAXReader.read(SAXReader.java:465)
	at org.dom4j.io.SAXReader.read(SAXReader.java:264)

I tried to do

        parser.isIncludeInternalDTDDeclarations= false
        parser.isIncludeExternalDTDDeclarations= false

which had no effect for me. How can I prevent the parser from following the link?

Sorting of element attributes

Currently, dom4j keeps the order of element attributes as they are. In some cases this may be the desired behavior. In other cases, a name ordering of attributes is required.

I need an option in org.dom4j.io.OutputFormat which allows me to specify a custom java.util.Comparator which determines the order of all attributes in elements. At least, it should be possible to implement a Comparator that orders by attribute name.

Add support for XPath 2.0

It seems dom4j is not capable of understanding some XPath 2.0 syntax.

Given the file:

<?xml version="1.0" encoding="UTF-8"?>
<note xmlns="http://example.org/note">
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
</note>

In fact when searching a node like so:

final XPath xPath = document.createXPath("/*:note/*:to");
final Node node = xPath.selectSingleNode(document);

dom4j throws an exception saying:

Caused by: org.dom4j.InvalidXPathException: Invalid XPath expression: /*:note/*:to Unexpected ':'
	at org.dom4j.xpath.DefaultXPath.parse(DefaultXPath.java:355) ~[dom4j-2.1.1.jar:na]
	at org.dom4j.xpath.DefaultXPath.<init>(DefaultXPath.java:59) ~[dom4j-2.1.1.jar:na]
	at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:222) ~[dom4j-2.1.1.jar:na]
	at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:202) ~[dom4j-2.1.1.jar:na]
	at com.example.demo.DemoApplication.run(DemoApplication.java:34) [classes/:na]
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE]
	... 5 common frames omitted

It could be interessting to update current XPath specification to 2.0 in order to let dom4j be more friendly with XML using namespaces without prefix.

WDYT ?

starts-with() bug

for the attached xml file, which is converted from a json string, it returns null. however, for some other xml files with absolute same structure, just different inner text, it returns normally. when removed starts-with...., it always success, even if I just try starts-with(text(),'urn:li'), it will also success. so, in a word, it seems there is some bugs for starts-with() . I see same thing happen for contains().
//included/firstname/../objecturn[starts-with(text(),'urn:li:member:')]

DocumentHelper.parseText could be vulnerable to XML Injection

The DocumentHelper.parseText could be used to convert Strings to a Document Object. But the function uses SAXReader to parse XML String which is vulnerable to XML Injection. To deal with this problem, we always using setFeature function to disllow doctype and entity. However you use the SAXReader directly and do not offer any function to allow users to config those features. So I think this is a problem here and if users used DocumentHelper.parse and the string to convert was controled by user input such as GET or POST parameters, the application would be vulnerable to XML Injection.

Dom4j 2.1.1 has regression and is stripping entities

Hi there,

On the XWiki project we upgraded from dom4J 2.1.0 to 2.1.1 and found some regressions: dom4j is now stripping our entities from the XML.

FTR here's the jira issue on the XWiki side: https://jira.xwiki.org/browse/XWIKI-15694

Initially we thought the problem was coming from our upgrade of CSS4J and after debugging with CSS4J's author, we found that the issue is actually with dom4J 2.1.1, see https://groups.google.com/forum/#!topic/css4j/HlnlB2c8G4I

To reproduce, see the tests at https://groups.google.com/d/msg/css4j/HlnlB2c8G4I/FFGDUyVDAwAJ

Thanks

Release 2.0.0

Many enterprise projects can't use RC releases for obvious reasons. Are there any known blocking issues that prevent 2.0.0 release at this point?

DocumentException didn't initalize cause in the standard way and lose inner stack trace when using logback

In the class org.dom4j.DocumentException

public DocumentException(Throwable nestedException) {
	super(nestedException.getMessage());
	this.nestedException = nestedException;
}

public DocumentException(String message, Throwable nestedException) {
	super(message);
	this.nestedException = nestedException;
}

These two constructor function didn't assign inner exception to java.lang.Throwable.cause.
Instead,it used org.dom4j.DocumentException.nestedException.
When I used Logback to log the error,the inner exception stack is lost.

Currently, i used the following code to get around it.

public static void fillDom4jCause(Throwable t) {
	if (null == t) {
		return;
	}
	if (t instanceof org.dom4j.DocumentException) {
		Throwable inner = ((org.dom4j.DocumentException) t).getNestedException();
		if (null == inner)
			return;
		fillDom4jCause(inner);
		t.initCause(inner);
	}
	else {
		Throwable inner = t.getCause();
		if (null == inner)
			return;
		fillDom4jCause(inner);
	}
}

Illegal reflective access

While using Apache Directory Studio which bundles dom4j the following is warned trough the console:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.dom4j.io.SAXContentHandler (<...>/org.apache.servicemix.bundles.dom4j_1.6.1.5.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding()
WARNING: Please consider reporting this to the maintainers of org.dom4j.io.SAXContentHandler
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

I'm running Ubuntu 19.04 with openjdk-11. If any more debugging information is required to pinpoint the issue I'm happy to provide.

XMLWriter should reject illegal control characters

According to the XML specification only certain control characters (0x09, 0x0A, and 0x0D) may occur in XML content. The XMLWriter should reject other characters like 0x0C (\f), but doesn't.
To reproduce:

public class Dom4jTest {
    @Test(expected = Throwable.class)
    public void shouldRejectInvalidCharacters() throws IOException {
        Document doc = DocumentHelper.createDocument();
        Element text = DocumentHelper.createElement("TEXT");
        text.setText("\f");
        doc.add(text);
        StringWriter xml = new StringWriter();
        XMLWriter writer = new XMLWriter(xml, OutputFormat.createPrettyPrint());
        writer.write(doc);
    }
}

DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception

I am using dom4j in my java library module in android studio, on reading the xml file it throws this nested exception. I am unable to figure it out. I have run the same code in Intellij for java and it works fine. Any possible reason for this exception?

Error:(9, 8) error: 
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: 
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In 
the case of corrupt Gradle processes, you can also 
try closing the IDE and then killing all Java processes.

org.dom4j.dom.DOMElement.setNodeValue(String)

As of DOM4J 2.0.0, the implementation of the method org.dom4j.dom.DOMElement.setNodeValue(String) is empty. In contrast, in version 1.6.1 it calls DOMNodeHelper.setNodeValue(this, nodeValue);.

Is there a specific reason why it is empty or is it a bug/regression?

element "input" must be end of "</input>"

The element type "input" must be terminated by a matching closing tag "".Nested exception: the element type "input" must be terminated by the matching end tag "".

元素类型 "input" 必须由匹配的结束标记 "" 终止。 Nested exception: 元素类型 "input" 必须由匹配的结束标记 "" 终止。

How can I do? where can I stop this check? Or pass this element

Add an automatic module name

While I'm not an enthusiast of Java modularization, unfortunately Java libraries that aren't module-aware are increasingly being a source of compiler warnings as people migrate to newer JDKs.

It would help if dom4j set up an automatic module name in the Jar manifest, like:

Automatic-Module-Name: org.dom4j

I'm not familiar with gradle, but apparently the following would work:

jar {
  manifest {
    attributes('Automatic-Module-Name': 'org.dom4j')
  }
}

See https://guides.gradle.org/building-java-9-modules/#optional_add_code_automatic_module_name_code_manifest_entries_for_all_other_projects

Of course that a full module-info would also be a good thing, but the above solution is simple and solves the main issue of having to rely on generated module names.

Dom4j concurrency problem

This is related to Issue #15

The concurrency problem that has been previously raised is caused by misuse of SynchronizedMap. As noted in SynchronizedMap's javadoc, a synchronized-block must be placed around things that iterate the map (c.f. https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#synchronizedMap-java.util.Map-). The QNameCache.getQNames() method fails to do this resulting in the possibility of ConcurrentModificationExceptions if getQNames() is iterating in thread#1 while thread#2 is mutating the map.

The use of a ConcurrentHashMap (as proposed as an enhancement in #15) would address this, but is complicated by a desire to preserve the WeakReferences within the map. That is, a ConcurrentWeakHashMap would solve it, but that is a heavy lift.

Instead, I would propose we simply follow the recommendation of SynchronizedMap. Namely:

    public List<QName> getQNames() {
        List<QName> answer = new ArrayList<QName>();
        synchronized(noNamespaceCache) {
            answer.addAll(noNamespaceCache.values());
        }

        synchronized(namespaceCache) {
            for (Map<String, QName> map : namespaceCache.values()) {
                answer.addAll(map.values());
            }
        }

        return answer;
    }

This will eliminate the bug and make Dom4j thread-safe. Implementing #15 in the future would additionally make it performant.

Writer adds space before <![CDATA[..]]> content

Hello all,

XMLWriter.write adds spaces before and after CDATA in case if there were any Java whitespace characters around CDATA.
For example, taking as input such XML

<?xml version="1.0" encoding="UTF-8"?>
	<value>
		<![CDATA[SOME_VALUE]]>
	</value>

Reading it with DOMReader.read and than writing it XMLWriter.write we'll get the following output

<?xml version="1.0" encoding="UTF-8"?>

<value> <![CDATA[SOME_VALUE]]> </value>

Note that CDATA is being enveloped by spaces.

prettyPrint superfluous newline

If I set
outputFormat.setSuppressDeclaration(true);
the output begins with a newline.

this does not help either:
outputFormat.setNewLineAfterDeclaration(false);

(version: 1.6.1)

Getting error: premature end of file!

so my test codes:
@test
public void testXmlParsing() {
String queryUrl="https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?cmd=prlinks&dbfrom=pubmed&retmode=ref*&id=24919618,24919617,24919616,24919615,24919614,24919613,24919612,24919611,24919610,24919609,24919608,24919607,24919606,24919605,24919498,24919497,24919496,24919495,24919494,24919493,24919492,24919491,24919490,24919489,24919488,24919410,24919159,24918970,24918969,24918833,24918767,24918729,24918728,24918727,24918726,24918725,24918724,24918723,24918722,24918721,24918720,24918719,24918718,24918643,24918496,24918428,24918424,24918423,24918422,24918421,24918420,24918419,24918418,24918417,24918416,24918415,24918414,24918413,24918412,24918411,24918410,24918409,24918408,24918407,24918406,24918405,24918404,24918269,24918023,24918022,24917638,24917637,24917636,24917635,24917634,24917633,24917632,24917631,24917625,24917624,24917553,24917539,24917516,24917514,24917511,24917458,24917275,24917270,24917261,24917260,24917259,24917258,24917257,24917256,24917255,24917254,24917253,24917252,24917174,24916892,24916828,24916768,24916659,24916410,24916408,24916369,24916160,24916159,24916158,24916091,24916090,24916089,24916088,24916087,24916086,24916085,24916013,24916012,24915882,24915656,24915540,24915460,24915257,24915210,24915161,24915045,24914850,24914849,24914848,24914847,24914846,24914845,24914844,24914843,24914842,24914841,24914840,24914839,24914838,24914837,24914836,24914835,24914711,24914710,24914533,24913954,24913953,24913952,24913951,24913950,24913949,24913948,24913947,24913946,24913945,24913944,24913943,24913942,24913941,24913815,24913655,24913598,24913327,24913326,24913138,24913029,24913016,24912753,24912618,24912493,24912492,24912443,24911958,24911862,24911861,24911860,24911859,24911858,24911857,24911856,24911855,24911854,24911853,24911852,24911851,24911850,24911849,24911848,24911847,24911846,24911845,24911844,24911843,24911814,24911631,24911460,24911348,24911257,24911223,24911221,24911115,24911019,24910429,24910422,24910421,24910399,24910328,24910171,24910128,24909993,24909941,24909896,24909737,24909579,24909510,24909444,24909443,24909383,24909374,24909329,24909328,24909327,24909326,24909325,24909324,24909323,24909322,24909321,24909261,24909233,24909181,24909159,24909122,24909111,24908708,24908591,24908558,24908518,24908474,24908184,24908183,24908182,24908162,24908075,24908074,24907887,24907885,24907846,24907842,24907838,24907836,24907833,24907832,24907828,24907822,24907821,24907820,24907819,24907818,24907817,24907815,24907810,24907809,24907804,24907800,24907799,24907798,24907784,24907711,24907710,24907363,24907248,24907247,24907246,24907245,24907244,24907243,24907106,24907022,24907021,24906986,24906889,24906796,24906497,24906496,24906472,24906471,24906470,24906430,24906291,24906161,24906132,24906122,24906118,24906009,24906001,24905998,24905925,24905918,24905856,24905834,24905826,24905820,24905805,24905764,24905740,24905738,24905728,24905590,24905579,24905578,24905468,24905459,24905447,2490544,24905362,24905361,24905353,24905232,24905231,24905191,24905132,24905116,24905100,24905098,24905026,24905024,24905014,24904072,24904071,24904070,24904069,24904068,24904066,24904065,24903807,24903598,24903597,24903584,24903493,24903492,24903241,24903240,24903239,24902821,24902736,24902735,24902734,24902733,24902732,24902731,24902730,24902729,24902728,24902727,24902726,24902725,24902724,24902691,24902690,24902689,24902688,24902684,24902669,24902105,24902104,24902103,24902102,24902101,24902100,24902099,24902098,24902097,24902096,24902095,24902094,24902093,24902092,24902091,24902090,24902089,24902088,24902087,24902086,24901951,24901936,24901887,24901886,24901885,24901884,24901883,24901564,24901442,24901304,24901061,24901060,24901059,24901058,24901057,24899635,24899500,24899462,24899219,24899087,24899086,24898902,24898853,24898793,24898627,24898580,24898467,24898107,24898091,24898090,24898089,24898088,24898087,24898086,24898085,24898084,24897978,24897977,24897976,24897975,24897974,24897973,24897972,24897971,24897970,24897969,24897968,24897967,24897966,24897965,24897964,24897760,24897495,24897494,24897493,24897492,24897491,24897490,24897489,24897488,24897487,24897486,24897485,24897484,24897483,24897482,24897481,24897480,24897479,24897478,24897477,24897476,24897475,24897474,24897473,24897472,24897471,24897470,24897469,24897468,24897467,24897466,24897394,24897345,24897031,24897019,24897018,24897017,24897016,24897015,24897014,24897013,24897012,24896581,24896580,24896579,24896578,24896577,24896576,24896575,24896574,24896573,24896572,24896571,24896570,24896372,24896313,24896312,24896311,24896310,24896309,24896308,24896262,24896261,24896229,24895958,";
URL url = null;
try {
url = new URL(queryUrl);
} catch (MalformedURLException e) {
e.printStackTrace();
}
HttpURLConnection.setFollowRedirects(true);
HttpURLConnection huc = null;
try {
huc = (HttpURLConnection) url.openConnection();
} catch (IOException e) {
e.printStackTrace();
}
huc.setConnectTimeout(30601000);
try {
huc.setRequestMethod("GET");
} catch (ProtocolException e) {
e.printStackTrace();
}
huc.addRequestProperty("Accept-Charset", "UTF-8");
huc.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36");
huc.setRequestProperty("Connection", "keep-alive");

    huc.setInstanceFollowRedirects(true);
    try {
        huc.connect();
    } catch (IOException e) {
        e.printStackTrace();
    }

    InputStream is= null;
    try {
        is = huc.getInputStream();
    } catch (IOException e) {
        e.printStackTrace();
    }
    String theString = null;
    try {
        theString = IOUtils.toString(is, "UTF-8");
    } catch (IOException e) {
        e.printStackTrace();
    }
    System.out.println(theString);
    SAXReader reader=new SAXReader();
    try {
        Document doc=reader.read(is);
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    assertTrue(true);
}

My intellij giving me : premature end of file error for my code:
org.dom4j.DocumentException: Error on line 1 of document : Premature end of file. Nested exception: Premature end of file.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.dom4j.io.SAXReader.read(SAXReader.java:343)
at com.vantage.iseek.incremental.indexer.impl.GalaxyXmlParsingTest.testXmlParsing(GalaxyXmlParsingTest.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Nested exception:
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1019)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.dom4j.io.SAXReader.read(SAXReader.java:343)
at com.vantage.iseek.incremental.indexer.impl.GalaxyXmlParsingTest.testXmlParsing(GalaxyXmlParsingTest.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Nested exception: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1019)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.dom4j.io.SAXReader.read(SAXReader.java:343)
at com.vantage.iseek.incremental.indexer.impl.GalaxyXmlParsingTest.testXmlParsing(GalaxyXmlParsingTest.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Process finished with exit code 0

I had checked my xml via some online xml checking tools and found xml looking ok.
Can I avoid this error by any twaeking or something?

ThreadingTest sometimes fails

org.dom4j.ThreadingTest uses common AbstractTestCase.document field in multi-thread environment. It should be rewritten to single test (independent of AbstractTestCase). Common document field is not used in this test, so test fail is false positive.

addElement took too much time

It's my code:

org.dom4j.Element root = DocumentHelper.createElement("kml");//根节点是kml
Document document = DocumentHelper.createDocument(root);
document.setXMLEncoding("UTF-8");
//给根节点kml添加属性
root.addNamespace("", "http://www.opengis.net/kml/2.2");
root.addNamespace("gx", "http://www.google.com/kml/ext/2.2");
//给根节点kml添加子节点  Document
org.dom4j.Element documentElement = root.addElement("Document");

org.dom4j.Element folderDe = documentElement.addElement("Folder");
org.dom4j.Element folderName = folderDe.addElement("name");
folderName.setText("轨迹");

org.dom4j.Element Placemark = folderDe.addElement("Placemark");

org.dom4j.Element trackE = Placemark.addElement("gx:Track");

//points size is 23000,it took about 300 milliseconds.It's OK.
for (LatLng tp : points) {
      //double[] latlon = GCJ02ToWGS_84(tp.latitude, tp.longitude);
      trackE.addElement("gx:coord").setText("...");
}
//It took about 30000 milliseconds!!!!!
for (LatLng tp : points) {
      //double[] latlon = GCJ02ToWGS_84(tp.latitude, tp.longitude);
      trackE.addElement("time").setText("...");
}

Of which, this step takes too much time.

//It took about 30000 milliseconds!!!!!
for (LatLng tp : points) {
      //double[] latlon = GCJ02ToWGS_84(tp.latitude, tp.longitude);
      trackE.addElement("time").setText("...");
}

When I change .addElement("time") to .addElement("gx:time").
It took about 300 milliseconds too.

Sorry, my English is not good, I hope you can understand it.

java.lang.NoClassDefFoundError: org/jaxen/JaxenException

Hi,

if i execute this code:

Document doc = getDoc(file);

//get all tilesets
List<Node> tilesetNodes = doc.selectNodes("/map/tileset"); //<-- this line throws the exception

i get this exception:

java.lang.NoClassDefFoundError: org/jaxen/JaxenException

	at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:222)
	at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:202)
	at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:159)
	at com.jukusoft.mmo.engine.shared.map.parser.TmxParser.parse(TmxParser.java:66)
	at com.jukusoft.mmo.engine.shared.map.parser.TmxMapParser.parse(TmxMapParser.java:54)
	at com.jukusoft.mmo.engine.shared.map.parser.TmxMapParserTest.testParse(TmxMapParserTest.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.ClassNotFoundException: org.jaxen.JaxenException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 28 more

How can is fix this?
I am using version 2.1.1 of dom4j.

writer.writeOpen(x) doesn't write namespaces

When i create an element with namespaces it will not write out the namespaces.

def writeDocument(writer: XMLWriter) 
  val rss = doc.addElement("rss")
     .addNamespace("g", "http://base.google.com/ns/1.0")
     .addNamespace("c", "http://base.google.com/cns/1.0")
   writer.writeOpen(rss)  // => doesn't work <rss>
   writer.write(rss) // => works <rss xmlns:c="http://base.google.com/ns/1.0" ... >

A normal write also writes out the namespaces

However when i write it using attributes it writes out the tag with namespaces.

def writeDocument(writer: XMLWriter) 
  val rss = XML.createElement("rss")
     .addAttribute("xmlns:g", "http://base.google.com/ns/1.0")
     .addAttribute("xmlns:c", "http://base.google.com/cns/1.0")
 writer.writeOpen(rss) // => works <rss xmlns:c="http://base.google.com/ns/1.0" ... >

btw it is scala code but that shouldn't matter.

Java 11 Compatibility check: Dom4J

Hi,
We are reaching out to you to check Java 11 compatibility of the library Dom4J.

Could you help us by answering the following questions:

  1. Library Name:
  2. Latest version: <latest 1.1.1="" eg:="" version.="">
  3. Latest version Is the library compatible with Java 11 Compatible? (Y/N)
  4. Is the library supported with Java 11? (Y/N)
  5. (If “N” in compatibility or support) What is the versions that would be compatible and Supported?
  6. Date of support availability?

Appreciate your response by 19.08.2018.

Thanks,
Krzysztof Dragan,
PTC Inc. Contractor

XMLWriter does not escape supplementary unicode characters correctly

When the maximum allowed character is set to a positive value, an XMLWriter is supposed to encode any character with a Unicode code point higher then the maximum allowed character as a numeric character reference. However for supplementary Unicode characters the current implementation seams to generate a sequence of two invalid numeric character references instead of one valid.

To reproduce run:

import org.dom4j.io.XMLWriter;
import org.dom4j.io.OutputFormat;
import org.dom4j.tree.DefaultElement;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

class XmlBugDemo {
	public static void main(String[] arg) throws IOException {
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		OutputFormat format = OutputFormat.createPrettyPrint();
		format.setEncoding("US-ASCII");
		XMLWriter writer = new XMLWriter(stream, format);

		// this string contains a single unicode code point:
		// U+1F427 PENGUIN
		String penguin = "\ud83d\udc27";
		DefaultElement foo = new DefaultElement("foo");
		foo.addText(penguin);

		writer.write(foo);
		
		System.out.println(stream.toString("US-ASCII"));
	}
}

Expected result:

<foo>&#128039;</foo>

Actual result:

<foo>&#55357;&#56359;</foo>

Notes:
The actual result isn't even a well-formed xml:

$ xmllint bad.xml 
bad.xml:2: parser error : xmlParseCharRef: invalid xmlChar value 55357
<foo>&#55357;&#56359;</foo>
             ^
bad.xml:2: parser error : xmlParseCharRef: invalid xmlChar value 56359
<foo>&#55357;&#56359;</foo>
                     ^

Missing "xsdlib" dependency in dom4j pom.xml published on Maven Central

Hi guys,

I've had a problem using dom4j in some context and noticed the problem comes from the fact that dom4j's pom.xml (https://search.maven.org/remotecontent?filepath=org/dom4j/dom4j/2.1.0/dom4j-2.1.0.pom) doesn't define the net.java.dev.msv:xsdlib:2013.6.1 dependency, which is correctly defined in build.gradle at https://github.com/dom4j/dom4j/blob/master/build.gradle#L28

Would be great if you could fix this for the next release! :)

Thx

CVS directories left in the source tree

Hi,

There are some CVS directories left that could be removed:

xdocs/CVS
xdocs/benchmarks/CVS
xdocs/benchmarks/xpath/CVS
xml/CVS
xml/bean/CVS
xml/dtd/CVS
xml/jaxb/CVS
xml/moreover/CVS
xml/nitf/CVS
xml/relaxng/CVS
xml/schema/CVS
xml/swing/CVS
xml/xhtml/CVS

Email address to report security issues?

Hi,

I believe I've found a security issue with the existing dom4j. Rather than create an issue noting them, I'd prefer to email someone so they can be fixed and then disclosed. Is there an email address I can use to do this?

dom4j read "&#09;" and then write it into file, cause a bug

with a source xml like:
<input value="test&#09;" />
then read it, it will be change to:
<input value="test " />
then write it to xml file, it will be written in xml file with those:
<input value="test " />
What I want is:
<input value="test&#09;" />

What I want is that didn't change the value of input when writing into a xml file.

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.