You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by ji...@apache.org on 2004/05/06 10:15:56 UTC

[jira] Created: (XERCESJ-953) context location bug

Message:

  A new issue has been created in JIRA.

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCESJ-953

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCESJ-953
    Summary: context location bug
       Type: Bug

     Status: Unassigned
   Priority: Major

    Project: Xerces2-J
 Components: 
             XInclude 1.0
   Versions:
             2.6.1

   Assignee: 
   Reporter: Manos Batsis

    Created: Thu, 6 May 2004 1:15 AM
    Updated: Thu, 6 May 2004 1:15 AM
Environment: Tested and reproduced on Linux and Windows 2000. In both cases, i was actually using an Ant 1.6.1 installation.

Description:
The following description was posted in xerces-j-user and uses windows path conventions.

===========
Description 
===========

[[[
I'm trying to patch up an xinclude task to automate some stuff but have "context" problems. My project structure (fragment):

xclude
└───testfiles
    │   include1.xml
    │   init.xml


My initial document (init.xml) is just

<?xml version="1.0" ?>
<test xmlns:xi="http://www.w3.org/2003/XInclude">
  <xi:include href="include1.xml" />
</test>

the include1.xml indeed exists in the same directory as the nitial document, however i get the following error:

 [Warning] :3:44: Include operation failed, reverting to fallback. Re
source error reading file as XML (href='include1.xml'). Reason: C:\tools
\eclipse\workspace\xclude\include1.xml (The system cannot find the path
specified)

So, although the init.xml was read from

C:\tools\eclipse\workspace\xclude\testfiles

the processor looks for the included file in

C:\tools\eclipse\workspace\xclude

]]]

=======================
Reproducing the problem
=======================
//Java code:

System.setProperty(				"org.apache.xerces.xni.parser.XMLParserConfiguration",		"org.apache.xerces.parsers.XIncludeParserConfiguration");

SAXParser parser = new SAXParser();
XMLSerializer serializer = new XMLSerializer(
		new FileOutputStream(this.out),
		new OutputFormat("XML", this.encoding, this.indent));
parser.setDocumentHandler(serializer.asDocumentHandler());

// THIS IS WHERE THE BUG IS, SEE WORKAROUNDS
// this.in is a java.io.File object
parser.parse(new InputSource(new FileInputStream(this.in)));

=================
Workarounds (two)
=================

1) Modify the initial document (init.xml above) by adding an xml:base in it's documentElement, having the absolut path of the file as the value.

2) Change the problematic line:

parser.parse(new InputSource(new FileInputStream(this.in)));

to this (the following works fine): 

parser.parse(new InputSource(this.in.getAbsolutePath()));


=========
Diagnosis
=========

My guess is this has something to do with the implementation of xml:base and the initial value that gets in xinclude processing, or some Locator problem?


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


[jira] Resolved: (XERCESJ-953) context location bug

Posted by ji...@apache.org.
Message:

   The following issue has been resolved as WON'T FIX.

   Resolver: Michael Glavassevich
       Date: Fri, 7 May 2004 10:53 AM

In your code snippet, a new InputSource which has been created from an InputStream is passed to parse. The reason it's not picking up the base URI for the parent document is because none was specified on the InputSource. When no base URI is specified, the parser will just default to the current working directory (user.dir).

In order for the include to resolve against the base URI of the parent, you need to specify the base URI of the parent:

InputSource src = new InputSource(...);
src.setSystemId("file:///C:/tools/eclipse/workspace/xclude/testfiles");
parser.parse(src);
---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCESJ-953

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCESJ-953
    Summary: context location bug
       Type: Bug

     Status: Resolved
   Priority: Major
 Resolution: WON'T FIX

    Project: Xerces2-J
 Components: 
             XInclude 1.0
   Versions:
             2.6.1

   Assignee: 
   Reporter: Manos Batsis

    Created: Thu, 6 May 2004 1:15 AM
    Updated: Fri, 7 May 2004 10:53 AM
Environment: Tested and reproduced on Linux and Windows 2000. In both cases, i was actually using an Ant 1.6.1 installation.

Description:
The following description was posted in xerces-j-user and uses windows path conventions.

===========
Description 
===========

[[[
I'm trying to patch up an xinclude task to automate some stuff but have "context" problems. My project structure (fragment):

xclude
&#9492;&#9472;&#9472;&#9472;testfiles
    &#9474;   include1.xml
    &#9474;   init.xml


My initial document (init.xml) is just

<?xml version="1.0" ?>
<test xmlns:xi="http://www.w3.org/2003/XInclude">
  <xi:include href="include1.xml" />
</test>

the include1.xml indeed exists in the same directory as the nitial document, however i get the following error:

 [Warning] :3:44: Include operation failed, reverting to fallback. Re
source error reading file as XML (href='include1.xml'). Reason: C:\tools
\eclipse\workspace\xclude\include1.xml (The system cannot find the path
specified)

So, although the init.xml was read from

C:\tools\eclipse\workspace\xclude\testfiles

the processor looks for the included file in

C:\tools\eclipse\workspace\xclude

]]]

=======================
Reproducing the problem
=======================
//Java code:

System.setProperty(				"org.apache.xerces.xni.parser.XMLParserConfiguration",		"org.apache.xerces.parsers.XIncludeParserConfiguration");

SAXParser parser = new SAXParser();
XMLSerializer serializer = new XMLSerializer(
		new FileOutputStream(this.out),
		new OutputFormat("XML", this.encoding, this.indent));
parser.setDocumentHandler(serializer.asDocumentHandler());

// THIS IS WHERE THE BUG IS, SEE WORKAROUNDS
// this.in is a java.io.File object
parser.parse(new InputSource(new FileInputStream(this.in)));

=================
Workarounds (two)
=================

1) Modify the initial document (init.xml above) by adding an xml:base in it's documentElement, having the absolut path of the file as the value.

2) Change the problematic line:

parser.parse(new InputSource(new FileInputStream(this.in)));

to this (the following works fine): 

parser.parse(new InputSource(this.in.getAbsolutePath()));


=========
Diagnosis
=========

My guess is this has something to do with the implementation of xml:base and the initial value that gets in xinclude processing, or some Locator problem?


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org