about xml:base when using multiple nested xi:include

Friday, 27 July 2018 · 4 messages · last reply 30 Jul 2018
MR
Marco Randazzo27 Jul 2018 14:21 #
Dear all, My example (in attachment) employs xi:include elements to include other xml files. The example is constituted by a main.xml file which includes another file (include1.xml) stored in a subfolder, called include1. include1.xml, in turn, includes another xml file (include2.xml) stored in a subfolder of include1 which is called include2. Overall, the example consists of four folder levels and only the last file, include4.xml, contains data. When I import main.xml in baseX, I obtain the following result:
<main xmlns:xi="http://www.w3.org/2001/XInclude">
  <level1 xml:base="./include1/include1.xml">
    <level2 xml:base="./include1/include2/include2.xml">
      <level3 xml:base="./include2/include3/include3.xml">
        <level4 xml:base="./include3/include4/include4.xml">
          <data>0</data>
          <data>1</data>
        </level4>
      </level3>
    </level2>
  </level1>
</main>
The xml tree is correct, but I have doubts about the value of the attribute xml:base. In particular: - level1: I think that the value of xml:base ( i.e. ./include1/include1.xml) is correct. - level2: xml:base value is correct if its meaning is a path relative to the root file. Otherwise, if xml:base is supposed to store a path relative to the current file, then it should be ./include2/include2.xml. - level3: This seems to be not correct, neither as an absolute path, nor as a relative path. I think it should be ./include1/include2/include3/include3.xml as a path relative to the root file or ./include3/include3.xml as a path relative to the current file. - level4: Same as level3. What do you think? Am I missing something? What are the specifications for the value of xml:base? Thank you, Marco Randazzo
CG
Christian Grün28 Jul 2018 14:56 #
Hi Marco, In BaseX, there’s just a little line of code that enables or disables XInclude [1]. If no one else reacts to your question, maybe people on a generic XML mailing lists (such as [2]) can give you better feedback on this. Ciao Christian [1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/build/xml/SAXWrapper.java#L63 [2] http://www.xml.org/xml-dev/
Quoted text · Marco Randazzo · 58 lines
On Fri, Jul 27, 2018 at 2:21 PM Marco Randazzo <Marco.Randazzo at iit.it> wrote: > > Dear all, > My example (in attachment) employs xi:include elements to include other xml files. > The example is constituted by a main.xml file which includes another file (include1.xml) stored in a subfolder, called include1. > > include1.xml, in turn, includes another xml file (include2.xml) stored in a subfolder of include1 which is called include2. > > Overall, the example consists of four folder levels and only the last file, include4.xml, contains data. > > > > When I import main.xml in baseX, I obtain the following result: > > > > <main xmlns:xi="http://www.w3.org/2001/XInclude"> > > <level1 xml:base="./include1/include1.xml"> > > <level2 xml:base="./include1/include2/include2.xml"> > > <level3 xml:base="./include2/include3/include3.xml"> > > <level4 xml:base="./include3/include4/include4.xml"> > > <data>0</data> > > <data>1</data> > > </level4> > > </level3> > > </level2> > > </level1> > > </main> > > > > The xml tree is correct, but I have doubts about the value of the attribute xml:base. > In particular: > > - level1: I think that the value of xml:base ( i.e. ./include1/include1.xml) is correct. > > - level2: xml:base value is correct if its meaning is a path relative to the root file. Otherwise, if xml:base is supposed to store a path relative to the current file, then it should be ./include2/include2.xml. > > - level3: This seems to be not correct, neither as an absolute path, nor as a relative path. I think it should be ./include1/include2/include3/include3.xml as a path relative to the root file or ./include3/include3.xml as a path relative to the current file. > > - level4: Same as level3. > > > > What do you think? Am I missing something? What are the specifications for the value of xml:base? > Thank you, > Marco Randazzo
MR
Marco Randazzo30 Jul 2018 16:20 #
Dear Chrstian,
Thank you for your answer.
I'm going to post the question in [2].
In the meanwhile, I did some other tests, whose results seems very strange to me.
I run the following xquery on the same xml file generated by the example attached in the first email (here reported) :
let $mydoc :=
<main xmlns:xi="http://www.w3.org/2001/XInclude">
  <level1 xml:base="./include1/include1.xml">
    <level2 xml:base="./include1/include2/include2.xml">
      <level3 xml:base="./include2/include3/include3.xml">
        <level4 xml:base="./include3/include4/include4.xml">
          <data>0</data>
          <data>1</data>
        </level4>
        <level4b>
          <data>0b</data>
          <data>1b</data>
        </level4b>
        <data>2</data>
        <data>3</data>
      </level3>
    </level2>
  </level1>
</main>
return base-uri($mydoc//level3)
The result returned by function base-uri is: file:///C:/software/test_include/include1/include1/include2/include2/include3/include3.xml which I think is wrong, I think it should be: file:///C:/software/test_include/include1/include2/include3/include3.xml
Quoted text · Christian Grün · 70 lines
-----Original Message----- From: Christian Grün <christian.gruen at gmail.com> Sent: Saturday, July 28, 2018 2:57 PM To: Marco Randazzo <Marco.Randazzo at iit.it> Cc: BaseX <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] about xml:base when using multiple nested xi:include Hi Marco, In BaseX, there’s just a little line of code that enables or disables XInclude [1]. If no one else reacts to your question, maybe people on a generic XML mailing lists (such as [2]) can give you better feedback on this. Ciao Christian [1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/build/xml/SAXWrapper.java#L63 [2] http://www.xml.org/xml-dev/ On Fri, Jul 27, 2018 at 2:21 PM Marco Randazzo <Marco.Randazzo at iit.it> wrote: > > Dear all, > My example (in attachment) employs xi:include elements to include other xml files. > The example is constituted by a main.xml file which includes another file (include1.xml) stored in a subfolder, called include1. > > include1.xml, in turn, includes another xml file (include2.xml) stored in a subfolder of include1 which is called include2. > > Overall, the example consists of four folder levels and only the last file, include4.xml, contains data. > > > > When I import main.xml in baseX, I obtain the following result: > > > > <main xmlns:xi="http://www.w3.org/2001/XInclude"> > > <level1 xml:base="./include1/include1.xml"> > > <level2 xml:base="./include1/include2/include2.xml"> > > <level3 xml:base="./include2/include3/include3.xml"> > > <level4 xml:base="./include3/include4/include4.xml"> > > <data>0</data> > > <data>1</data> > > </level4> > > </level3> > > </level2> > > </level1> > > </main> > > > > The xml tree is correct, but I have doubts about the value of the attribute xml:base. > In particular: > > - level1: I think that the value of xml:base ( i.e. ./include1/include1.xml) is correct. > > - level2: xml:base value is correct if its meaning is a path relative to the root file. Otherwise, if xml:base is supposed to store a path relative to the current file, then it should be ./include2/include2.xml. > > - level3: This seems to be not correct, neither as an absolute path, nor as a relative path. I think it should be ./include1/include2/include3/include3.xml as a path relative to the root file or ./include3/include3.xml as a path relative to the current file. > > - level4: Same as level3. > > > > What do you think? Am I missing something? What are the specifications for the value of xml:base? > Thank you, > Marco Randazzo
CG
Christian Grün30 Jul 2018 20:21 #
Hi Marco,
Quoted text · Marco Randazzo · 4 lines
> The result returned by function base-uri is: > file:///C:/software/test_include/include1/include1/include2/include2/include3/include3.xml > which I think is wrong, I think it should be: > file:///C:/software/test_include/include1/include2/include3/include3.xml
The answer is correct (you will see this if you try other XQuery processors): Your resulting base uri is composed by recursively resolving the relative base URIs. A simplified example:
  base-uri(
    <a xml:base="a/">
      <b xml:base="b/">
        <c xml:base="c.xml"/>
      </b>
    </a>//c
  )
The base URIs are: • element a: ...original base uri.../a/ • element b: ...original base uri.../a/b/ • element c: ...original base uri.../a/b/c.xml Cheers Christian PS: Feel free to forward a potential answer to the XInclude issue to this list.

⚡Generated with XQuery