Re: [basex-talk] Optimized query for importing content based on metadata

2018-10-19 Thread Christian Grün
Hi Jason,

My version would have looked pretty similar:

  let $xmlroot := '/Users/jason.davis/Sandbox/dita-docs/content/'
  for $path in file:list($xmlroot, true())
  where matches($path, '\.(xml|ditamap)$')
  let $doc := doc($xmlroot || $path)
  where $doc//brand[contains(., 'xyz')]
  return db:add('d4st^dita-docs^meta-test', $doc, $path)

If you have already openen the document, you can directly pass it on to db:add.

Cheers,
Christian


On Fri, Oct 19, 2018 at 11:01 PM Jason Davis
 wrote:
>
> Hi,
>
> I’ve cobbled together a query that I want to use to import xml from the 
> filesystem into the database based on specific metadata requirements:
>
> let $xmlroot := "/Users/jason.davis/Sandbox/dita-docs/content/"
>for $file in file:list($xmlroot, true())
>where matches($file, 'xml') or matches($file, 'ditamap')
>let $doc := file:resolve-path($file, $xmlroot)
>return if (doc($doc)//brand[contains(.,'xyz')])
>then db:add("d4st^dita-docs^meta-test",  $doc)
>else ()
>
> It works, so I’m pleased! I’m just wondering if there is a more efficient way 
> to achieve what I want to do. I know that using a specific XPath in the doc 
> function is one thing I can do better. Any suggestions are appreciated!
>
> Thanks,
> Jason


[basex-talk] Optimized query for importing content based on metadata

2018-10-19 Thread Jason Davis
Hi,

I’ve cobbled together a query that I want to use to import xml from the 
filesystem into the database based on specific metadata requirements:

let $xmlroot := "/Users/jason.davis/Sandbox/dita-docs/content/"
   for $file in file:list($xmlroot, true())
   where matches($file, 'xml') or matches($file, 'ditamap')
   let $doc := file:resolve-path($file, $xmlroot)
   return if (doc($doc)//brand[contains(.,'xyz')])
   then db:add("d4st^dita-docs^meta-test",  $doc)
   else ()

It works, so I’m pleased! I’m just wondering if there is a more efficient way 
to achieve what I want to do. I know that using a specific XPath in the doc 
function is one thing I can do better. Any suggestions are appreciated!

Thanks,
Jason




Re: [basex-talk] Reflect.forName() / Performance

2018-10-19 Thread Christian Grün
Hi Tom,

Thanks for the XQuery example.

Your hint was helpful: If a function signature is not registered yet
when it is parsed, all kind of lookups are performed to locate the
function. This is e.g. the case if the function is recursive, or if
the invoked functions occurs after the currently parsed code.

I have revised the code which is responsible for locating invoked
functions: In the JavaFunction class [1], the lookup will be avoided
if we can tell in advance that no Java class will be found.

A new snapshot is online [2]; looking forward to your profiling results,
Christian

[1] 
https://github.com/BaseXdb/basex/commit/878c70fa3e1ef8ec6ab1f08b31f83e3157fc04c0#diff-2593cd6d13416ce7a77f1fba8f42a177R197
[2] http://files.basex.org/releases/latest/




> Given the following module (installed with module install foo.xqm):
>
> module namespace uc = 'http://unifits.com/common';
> declare function uc:remove-elements($input as element(), $remove-names as 
> xs:string*) as element() {
>   element {node-name($input) }
>   {$input/@*,
> for $child in $input/node()[not(local-name() = $remove-names)]
> return
>   if ($child instance of element())
>   then uc:remove-elements($child, $remove-names)
>   else $child
>}
> };
>
>
> if I start BaseXGui in debug mode, and set a breakpoint in
> Reflect.forName(), every time I execute a query such as
>
> import module namespace uc = 'http://unifits.com/common';
> /
>
> the breakpoint is hit, i.e. Class.forName() is called.
> I *think* this might have to do with the fact that the function above is
> recursive, but I have to admit that I don't really grasp the code that
> does the module loading/parsing.
>
> Thanks,
> -tom


Re: [basex-talk] Importing XML (DITA) validated with Relax NG schemas?

2018-10-19 Thread Christian Grün
Hi Radu,

Thanks for trying to get this working.

> - I created a new database.
> - Added an XML document to the database, the XML document containing a
> reference to the RNG schema.

Just a guess: You may need to supply the catalog before adding the
document to the database. In the GUI, if you open the Database → New…
dialog, you can specify the file via the parser dialog. Adding the
path in the .basex file should work as well (it doesn’t matter if you
specify a local file path or a file:// URI).

> Will I find that extra logging in the console I used to start
> "basexhttp.bat"? Or do I need to first configure the logging?

If you start basex instances with the -d flag, you’ll get some more feedback.

Hope this helps, further questions are welcome,
Christian


Re: [basex-talk] Importing XML (DITA) validated with Relax NG schemas?

2018-10-19 Thread Radu Coravu

Hi Christian,

Sorry for the delay, I installed a BaseX server on my side just to test 
things out but I have not used BaseX before.


So:

- I created a new database.
- Added an XML document to the database, the XML document containing a 
reference to the RNG schema.
- Add an extra XML catalog to the BaseX configuration. In the ".basex" 
config file I added:



CATFILE=file:/D:/projects/eXml/frameworks/dita/DITA-OT2.x/catalog-dita.xml


Did I correctly add the reference to the XML catalog or should it be a 
file-like path instead?

For example if I

- Added the "dita-ng.jar" to the "lib/custom" folder. I thought things 
out and the "dita-ng.jar" does not need to be added with high priority 
in the class path, just adding it there should be enough.


- Create a new XQuery which loads the XML document and tries to list the 
root element (in order to see if the default attributes are loaded or not).


- Run the XQuery and I can do that as well as I installed an add-on for 
Oxygen XML Editor which allows me to run an XQuery:


http://argon-author.com/

After running the XQuery the returned XML content does not contain the 
default attributes expanded. So it does not work.


I will try to find more time to add some System.err's in the Java code 
of the "dita-ng.jar" and re-pack it, restart the server.
Will I find that extra logging in the console I used to start 
"basexhttp.bat"? Or do I need to first configure the logging?


Regards,
Radu

Radu Coravu
 XML Editor
http://www.oxygenxml.com

On 10/18/2018 12:16 AM, Christian Grün wrote:

Hi Radu,

Do you think the DITA parsing should work if dita-ng.jar is placed first
in the classpath?

Cheers,
Christian




Jason Davis mailto:jason.da...@hortonworks.com>> schrieb am Mo., 15. Okt. 2018, 17:46:

Hi Christian, Radu,

I’ve tried adding the dita-ng.jar to the lib/custom dir of basex and
then manually modified the startup script to load it first. I can
even confirm that it’s the first jar on the path using:

proc:property('java.class.path')

However, the database still fails to parse the XML with default
attributes applied. I find myself having to cobble together an
undesirable workaround whereby I manually supply the default
attribute values myself in order to get my project to work with
BaseX. Do you have any further suggestions for how I might get this
to work?

Thanks,
Jason

On 10/3/18, 3:24 AM, "Christian Grün" mailto:christian.gr...@gmail.com>> wrote:

Hi Jason (cc to the list),

> I set the CP variable like so:
>

CP=$MAIN/BaseX.jar:$MAIN/lib/custom/dita-ng.jar:$MAIN/lib/*:$MAIN/lib/custom/*:$CLASSPATH
>
> This appears to be slightly different than the example you
linked Christian. I’m using BaseX 9.0.2. Does this make a difference?

The start scripts in the official distributions are created from the
GitHub examples I linked, so they are slightly different.

> I added an echo $CLASSPATH line under the CP variable. When I
run the script, the echo statement is blank.

In the script, no value will be bound to the $CLASSPATH variable.
Instead, you can assign values to this variable by yourself, which
will then be appended to the $CP variable. If you didn’t do so,
and if
your Linux environment does not have any other values assigned
to this
variable (which is the default), the output will necessarily be
empty.

> Is there a way to see how the classpath is set when running
this script?

To answer the "how": It will be set via the line that you will find
some lines below in the script, and the -cp Java argument:

  exec java -cp "$CP" $BASEX_JVM org.basex.BaseX "$@"

If you want to know which value is bound to $CP, try "echo $CP". In
Java, the full user class path at runtime will be bound to the
"java.class.path" system property. It can e.g. be retrieved via
proc:property('java.class.path') [1].

Christian

[1] http://docs.basex.org/wiki/Process_Module#proc:property