search xi:inlude in xpath without resolving

<oXygen/> general issues.
Doug
Posts: 28

search xi:inlude in xpath without resolving

Tue Feb 14, 2017 3:38 am

Hi, this seems like it should be easy but I can't solve it or find an answer. I want to find xi:include elments via xpath, not what the xi:includes resloves to. I can't seem to do this with either the xpath dialog or the xpath/xquery builder.

//xi:include returns no results. But //bibliomixed does. <bibliomixed> elements are referenced by the xi:includes. More specifically I want to execute the following xquery which returns empty <by-owc> elements, which is not what I want or expect. There are matches in in the source document for all the xpointer values.

Code: Select all

declare default element namespace "http://docbook.org/ns/docbook";
declare namespace xi="http://www.w3.org/2001/XInclude";

declare variable  $source-doc := doc("hraf.docbook.bib_source.xml");
declare variable $owc-doc := doc("hraf.docbook.bib_by_owc.xml");

<sets xmlns="http://docbook.org/ns/docbook">
{
for  $source-id in $source-doc//bibliomixed/@xml:id/string()
return
<set>
<source> {$source-id}</source>
<by-owc>{$owc-doc//xi:include[@xpointer=$source-id]/@xpointer/string()}</by-owc>
</set>
}
</sets>


I can search for elements inside the xi:include element after it has been resolved. My document with the xi:includes looks something like below, though with many more <xi:include> elements.:

Code: Select all

<bibliography xmlns:xi="http://www.w3.org/2001/XInclude"
              xmlns:xlink="http://www.w3.org/1999/xlink"
              xmlns="http://docbook.org/ns/docbook"
              role="hraf-collection-materials-global-bibliography"
              ocms="113">
   <bibliodiv>
      <title>AQ43 Early Indus</title>
      <xi:include href="hraf.docbook.bib_source.xml"
         xpointer="Dales1979TheBalakotProjectSummaryofFourYearsofExcavationsinPakistan"/>
      <xi:include href="hraf.docbook.bib_source.xml"
         xpointer="Durrani1988ExcavationsintheGomalValleyRehmanDheriExcavationReportNo1"/>
      <xi:include href="hraf.docbook.bib_source.xml"
         xpointer="Durrani1991FurtherExcavationsatRehmanDheri"/>
   </bibliodiv>
</bibliography>


and my document pointed to by the xi:includes looks something like below, though with many more <bibliomixed> elements. The matches aren't shown because the two documents are ordered differently.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<bibliography xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook"
    role="hraf-collection-materials-global-bibliography" ocms="113">
    <bibliomixed xml:id="blank-template"/>
    <bibliomixed xml:id="Agboton1997CulturedesPeuplesduBnin">
        <info>
            <sid uuid="aa94f366-14bd-4af3-a782-a1042d0e1bf1">
                <sowc code="fa18" term="Fon">
                    <socm code="113" term="Bibliographies in sources"/>
                </sowc>
            </sid>
        </info>
        <author>
            <personname>
                <surname>Agboton</surname>, Gaston A. M.</personname>
        </author>
        <pubdate>1997</pubdate>. <title role="book">Culture des Peuples du Bénin</title>. Dakar,
        Senegal: Présence Africaine.</bibliomixed>
    <bibliomixed xml:id="Alladaye2003LeCatholicismeauPaysduVodun">
        <info>
            <sid uuid="ce82800e-6400-41e3-89b6-0d497b7065e3">
                <sowc code="fa18" term="Fon">
                    <socm code="113" term="Bibliographies in sources"/>
                </sowc>
            </sid>
        </info>
        <author>
            <personname>
                <surname>Alladaye</surname>, Jérôme.</personname>
        </author>
        <pubdate>2003</pubdate>. <title role="book">Le Catholicisme au Pays du Vodun</title>.
        Cotonou, Benin: Editions Flamboyant.</bibliomixed>
 </bibliography>
adrian
Posts: 2326

Re: search xi:inlude in xpath without resolving

Tue Feb 14, 2017 5:32 pm

Hi,

By default Oxygen enables XInclude processing. This means the XIncludes are replaced with the actual content they indicate during XML parsing. As a result there's no xi:include in the XML model to be matched by an XPath.

There is an option to disable this, but note that it is global, affects XInclude everywhere in Oxygen (transformation, validation, etc), not just XPath.
Go to Options > Preferences, XML > XML Parser and clear the box for "Enable XInclude processing".
Note that this means the XIncluded content will no longer be resolved.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Doug
Posts: 28

Re: search xi:inlude in xpath without resolving

Tue Feb 14, 2017 5:46 pm

Perfect Adrian. Thanks! That did it. I really thought it should be a configuration option, and I thought maybe I had seen such a setting sometime ago, but I failed to find it. I was lookng for transformation engine settings instead of parser settings.

My real goal here is to update the the xpointer values on both sides of a source and xi:include set with a new format for the value. This should allow me to do this. If I'm also missing some way I can do this automatically, sort of in a sql cascading update fashion, just by changing the source value, versus my planned xquery update, please let me know.
adrian
Posts: 2326

Re: search xi:inlude in xpath without resolving

Tue Feb 14, 2017 7:08 pm

Hi,

So, if I understand correctly you want to update both the /xi:include/@xpointer value and the targeted @xml:id value.
What you need is to create a custom XML refactoring operation for Oxygen. Incidentally this also disables XInclude processing during the operation. So you no longer need to tamper with that XInclude option. More details about it here: Custom Refactoring Operations

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Doug
Posts: 28

Re: search xi:inlude in xpath without resolving

Tue Feb 14, 2017 8:38 pm

Thanks Adrian. Yes, that is correct "you[I] want to update both the /xi:include/@xpointer value and the targeted @xml:id value". The Custom Refactoring Operation looks very useful. For this first time through I have succeeded with my one-off xquery update, but I will try the option you suggest for future synching of my @xpointer and targeted @xml:id values, particularly for editors who aren't programmers.

By the way, its probably irrelevant but I think of my needs in the opposite direction that you listed them, i.e. when the @xml:id value targeted by the //xi:include/@xpointer value changes, I want the the @xpointer value to change in-synch.

Also, by the way, since there is a one-to-many, including one-to-zero, relationship between my source elements with @xml:id attributes and my xi:include elements, my xquery update was a bit tricky for me, but I was pleased to make it work in the xquery builder window, with the right combination of parentheses, commas, and inner loops. I will save it as a favorite and as I expect I will need something similar when building the Custom Refactoring Operation.

Which brings up a feature request. As far as I've been able to figure out in the xquery builder window I can't modify a previously saved favorite in the xpath/xquery builder window and save the modifications with the same favorite name. I have to save the version with the new modifications with a new name and/or delete the old favorite first. Similarly I can't rename favorites. Can it be made possible in the future to save modifications to a favorite and keep the old name and be able to rename favorites? I realize that at some point I might as well save to file but I write alot of almost but not quite one-offs.
adrian
Posts: 2326

Re: search xi:inlude in xpath without resolving

Wed Feb 15, 2017 8:06 pm

Hi,

For this first time through I have succeeded with my one-off xquery update, but I will try the option you suggest for future synching of my @xpointer and targeted @xml:id values, particularly for editors who aren't programmers.
Editors who aren't programmers are precisely the intended beneficiaries of custom refactoring operations.

By the way, its probably irrelevant but I think of my needs in the opposite direction that you listed them, i.e. when the @xml:id value targeted by the //xi:include/@xpointer value changes, I want the the @xpointer value to change in-synch.
Refactoring can work both ways, could update both (or multiple) values (the declaration and references), but I guess it depends on your use case.

Which brings up a feature request. As far as I've been able to figure out in the xquery builder window I can't modify a previously saved favorite in the xpath/xquery builder window and save the modifications with the same favorite name. I have to save the version with the new modifications with a new name and/or delete the old favorite first. Similarly I can't rename favorites. Can it be made possible in the future to save modifications to a favorite and keep the old name and be able to rename favorites? I realize that at some point I might as well save to file but I write alot of almost but not quite one-offs.
I guess we could easily allow to replace an existing favorite. Not sure why that wasn't implemented in the first place.
Renaming favorites is a different matter, I'll log a different request for that.


Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
teo
Posts: 6

Re: search xi:inlude in xpath without resolving

Mon Oct 02, 2017 3:13 pm

Hello Douglas,

We released Oxygen XML Editor 19.1 a couple of days ago and the feature you requested is now available.
You can now save modifications to a favorite expression and keep its old name (in the XPath/XQuery builder).

Best Regards,
Teo
Teodor Timplaru
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 1 guest