[dom4j-dev] [ dom4j-Bugs-2810839 ] Comment before document element break transform

2009-06-24 Thread SourceForge.net
Bugs item #2810839, was opened at 2009-06-23 13:20
Message generated for change (Comment added) made by szegedia
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=2810839&group_id=16035

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Attila Szegedi (szegedia)
Assigned to: Nobody/Anonymous (nobody)
Summary: Comment before document element break transform

Initial Comment:
I have a trivial document (saved as "id.xml"):



And a trivial XSLT file (saved as "ad.xslt") that's just an identity transform:

http://www.w3.org/1999/XSL/Transform"; version='1.0'>







The following code, using no dom4j but just built-in javax.xml.parsers.* works, 
and prints a non-null element:

import java.io.File;
import java.net.URL;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document;

public class XsltTest {
public static void main(String[] args) throws Exception {
final Source docSource = new 
DOMSource(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new 
File("id.xml"))); 
final DOMResult result = new DOMResult(); 
TransformerFactory.newInstance().newTransformer(new StreamSource(
new File("ad.xslt"))).transform(docSource, result);
final Document doc = (Document)result.getNode();
System.out.println(doc.getDocumentElement());
}
}

It prints "[x: null]", as expected.

Now, replacing the "final Source docSource" declaration with a dom4j Document 
(using DOMDocumentFactory):

final SAXReader reader = new SAXReader();
reader.setDocumentFactory(new DOMDocumentFactory());
final Source docSource = new DOMSource((Document)reader.read(new 
File("id.xml"))); 

will cause the program to print "null" - the transformed document now has no 
root element! 

Removing the comment from before  fixes the problem, so it's the comment 
that makes it fail.

This is with 1.6.1

--

>Comment By: Attila Szegedi (szegedia)
Date: 2009-06-24 09:18

Message:
For now, worked around it with a private build of dom4j. NOTE: I didn't
find and fix the bug, I worked around it. What I did is I took the
SAXReader.read(InputSource) method and doctored it so that it removes any
top-level comments from the document before returning it. Would still
prefer a proper fix.

--

Comment By: Attila Szegedi (szegedia)
Date: 2009-06-23 13:22

Message:
It's possibly related to


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=2810839&group_id=16035

--
___
dom4j-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev


[dom4j-dev] [ dom4j-Bugs-2810839 ] Comment before document element break transform

2009-06-23 Thread SourceForge.net
Bugs item #2810839, was opened at 2009-06-23 13:20
Message generated for change (Tracker Item Submitted) made by szegedia
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=2810839&group_id=16035

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Attila Szegedi (szegedia)
Assigned to: Nobody/Anonymous (nobody)
Summary: Comment before document element break transform

Initial Comment:
I have a trivial document (saved as "id.xml"):



And a trivial XSLT file (saved as "ad.xslt") that's just an identity transform:

http://www.w3.org/1999/XSL/Transform"; version='1.0'>







The following code, using no dom4j but just built-in javax.xml.parsers.* works, 
and prints a non-null element:

import java.io.File;
import java.net.URL;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document;

public class XsltTest {
public static void main(String[] args) throws Exception {
final Source docSource = new 
DOMSource(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new 
File("id.xml"))); 
final DOMResult result = new DOMResult(); 
TransformerFactory.newInstance().newTransformer(new StreamSource(
new File("ad.xslt"))).transform(docSource, result);
final Document doc = (Document)result.getNode();
System.out.println(doc.getDocumentElement());
}
}

It prints "[x: null]", as expected.

Now, replacing the "final Source docSource" declaration with a dom4j Document 
(using DOMDocumentFactory):

final SAXReader reader = new SAXReader();
reader.setDocumentFactory(new DOMDocumentFactory());
final Source docSource = new DOMSource((Document)reader.read(new 
File("id.xml"))); 

will cause the program to print "null" - the transformed document now has no 
root element! 

Removing the comment from before  fixes the problem, so it's the comment 
that makes it fail.

This is with 1.6.1

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=2810839&group_id=16035

--
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
___
dom4j-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev


[dom4j-dev] [ dom4j-Bugs-2810839 ] Comment before document element break transform

2009-06-23 Thread SourceForge.net
Bugs item #2810839, was opened at 2009-06-23 13:20
Message generated for change (Comment added) made by szegedia
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=2810839&group_id=16035

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Attila Szegedi (szegedia)
Assigned to: Nobody/Anonymous (nobody)
Summary: Comment before document element break transform

Initial Comment:
I have a trivial document (saved as "id.xml"):



And a trivial XSLT file (saved as "ad.xslt") that's just an identity transform:

http://www.w3.org/1999/XSL/Transform"; version='1.0'>







The following code, using no dom4j but just built-in javax.xml.parsers.* works, 
and prints a non-null element:

import java.io.File;
import java.net.URL;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document;

public class XsltTest {
public static void main(String[] args) throws Exception {
final Source docSource = new 
DOMSource(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new 
File("id.xml"))); 
final DOMResult result = new DOMResult(); 
TransformerFactory.newInstance().newTransformer(new StreamSource(
new File("ad.xslt"))).transform(docSource, result);
final Document doc = (Document)result.getNode();
System.out.println(doc.getDocumentElement());
}
}

It prints "[x: null]", as expected.

Now, replacing the "final Source docSource" declaration with a dom4j Document 
(using DOMDocumentFactory):

final SAXReader reader = new SAXReader();
reader.setDocumentFactory(new DOMDocumentFactory());
final Source docSource = new DOMSource((Document)reader.read(new 
File("id.xml"))); 

will cause the program to print "null" - the transformed document now has no 
root element! 

Removing the comment from before  fixes the problem, so it's the comment 
that makes it fail.

This is with 1.6.1

--

>Comment By: Attila Szegedi (szegedia)
Date: 2009-06-23 13:22

Message:
It's possibly related to


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=2810839&group_id=16035

--
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
___
dom4j-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev