XSLT 3 how to write a package - xslt-3.0

I tried to learn package then I started and copied the working example from the xslt 3 specification but I cannot use the package.
In the template where I use I got an error:
The package cannot be found.
What did I do wrong? I expect something with name or xmlns declaration
The only thing I changed is http://example.com/csv-parser to http://flexibatch.com/fhx-parser and its related xmlns declaration.
Flexibatch.com is as fictional as example.com
Thanks for your help

If you are running Saxon 9 inside oXygen, then I think one option to use packages is the create and use a Saxon configuration file (oXygen supports creating that file type with new file -> Saxon configuration where you have an option to open the section [xsltPackages] where you can then relate the name of a package to a sourceLocation or exportLocation).
Then in the transformation scenario in the extended Saxon options you can specify the Saxon configuration file to use and that way Saxon will know how to find any package your main module uses with xsl:use-package (https://www.w3.org/TR/xslt-30/#element-use-package) because it can relate the URI/name given there to a package location.
It is a bit of a complicated setup, perhaps add a tag for oXygen so that their support guys see your question and can tell you any more or easier options.
An example section from a Saxon config file to use the package directly from the XSLT 3 test suite is
<xsltPackages>
<package name="http://example.com/csv-parser" version="1.0"
sourceLocation="https://github.com/w3c/xslt30-test/raw/master/tests/decl/package/package-100.xsl"/>
</xsltPackages>
of course you can adapt the source location if you have a local file and you need to adapt the name if you have done that as your question suggests.
The XSLT code to use that package is online viewable at https://github.com/w3c/xslt30-test/blob/master/tests/decl/package/package-100a.xsl (or executable/downloadable at https://github.com/w3c/xslt30-test/raw/master/tests/decl/package/package-100a.xsl) and is
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:csv="http://example.com/csv"
exclude-result-prefixes="xs csv" version="3.0">
<xsl:output indent="yes"/>
<!-- example input "file" -->
<xsl:variable name="input" as="xs:string"
>name,id,postal code
"Abel Braaksma",34291,1210 KA
"Anders Berglund",473892,9843 ZD</xsl:variable>
<!-- entry point -->
<xsl:template name="xsl:initial-template">
<xsl:copy-of select="csv:parse($input)"/>
</xsl:template>
<xsl:use-package name="http://example.com/csv-parser" package-version="*"/>
</xsl:stylesheet>
So you could start a transformation scenario in oXygen with the XSLT code linked directly from https://github.com/w3c/xslt30-test/raw/master/tests/decl/package/package-100a.xsl and the Saxon 9 specific settings using a configuration file with the above section.

It works with the config file but now I get an error message: « Cannot apply cascading transformation. Reason: .org.xml.sax.SAXParseException; systemId: file:/C:/..../Test-Package.xsl_xslt_cascade; lineNumber: 3; columnNumber: 9; Content not allowed in prolog. » (line 3 is xmlns:xsl=....)

Related

How do I fix this XML schema?

I am trying to use JAXB on my XML schema with IntelliJ Ultimate. This is the schema from the IndoorGML website. However, the IDE says there is something wrong with it.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.opengis.net/indoorgml/1.0/core"
xmlns:gml="http://www.opengis.net/gml/3.2" elementFormDefault="qualified" version="1.0.3">
<xs:annotation>
<xs:documentation>
IndoorGML is an OGC Standard. Copyright (c) 2014,2015,2016,2018 Open Geospatial Consortium. To obtain additional rights of use, visit http://www.opengeospatial.org/legal/.
</xs:documentation>
</xs:annotation>
<!--
======================================================================
-->
<xs:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
<!--
======================================================================
-->
<xs:element name="IndoorFeatures" type="IndoorFeaturesType" substitutionGroup="gml:AbstractFeature"/>
<!--
</xs:schema>
In the last line in substitutionGroup="gml:AbstractFeature", the IDE marks AbstractFeature in red with the message "Cannot resolve symbol 'gml:AbstractFeature'". Does anyone know why? (The XSD file has more tags before the closing schema tag which I didnt' put here because it's a couple hundred lines.)
Thanks in advance! :)
The reported error is on this reference: substitutionGroup="gml:AbstractFeature"
...which is attempting make 'IndoorFeatures' a member of a substitution group that is defined in another namespace.
But which namespace? The namespace identified by the prefix 'gml'. And which namespace is that? The answer is here: xmlns:gml="http://www.opengis.net/gml/3.2"
So we need to find out where that namespace is imported into this XSD. That is done here:
<xs:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
I think the reason for the error is fairly obvious now, but I will go ahead and complete the answer. The XSD which defines that namespace is identified here:
schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"
Clearly, your application cannot resolve that URL or is not allowed to access it.
How can you fix it?
If you can get a copy of the XSD then you can either
a) save it to a local folder and change the schemaLocation attribute to point to the local folder, or
b) Define a schema resolver that maps the URL to your folder location.
Not sure whether IntelliJ supports schema resolvers, but I expect it does.

Creating Custom Component using Moqui and mount using MoquiConf.xml

I'm fairly new to moqui and reaching out for some help with creating custom component using moqui and mount the application on webroot using MoquiConf.xml
I had read https://www.moqui.org/MakingAppsWithMoqui-1.0.pdf and created tutorial component and successfully mounted using the below section from https://www.moqui.org/MakingAppsWithMoqui-1.0.pdf
Add a subscreens-item element under the subscreens element in the apps.xml file like:
location="component://tutorial/screen/tutorial.xml"/>
However my understanding based on the reading from Moqui Documentation below -->
https://www.moqui.org/docs/framework/User+Interface/XML+Screen is that i should be able to mount a custom component using MoquiConf.xml -> screen-facade in my custom component directory, without having to make changes in apps.xml under webroot (i really like this idea)
For #4 (Moqui Conf XML File) you can put these elements in any of the Moqui Conf XML files that get merged into that runtime configuration. The main way to do this is in a MoquiConf.xml file in your component directory so the configuration is in the same component as the screens and you don't have to modify and maintain files elsewhere. See more details about the Moqui Conf XML options in the Run and Deploy instructions. Here is an example from the MoquiConf.xml file in the moqui/example component:
<screen-facade>
<screen location="component://webroot/screen/webroot/apps.xml">
<subscreens-item name="example" menu-title="Example" menu-index="97"
location="component://example/screen/ExampleApp.xml"/>
</screen>
</screen-facade>
However i was not able to get this to work, i tried the MoquiConf.xml approach in tutorial component and also made a copy of example component and still no joy, Appreciate any pointers
My Configuration from my attempt with tutorial project
component/tutorial/MoquiConf.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!-- No copyright or license for configuration file, details here are not considered a creative work. -->
<moqui-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/moqui-conf-2.1.xsd">
<screen-facade>
<screen location="component://webroot/screen/webroot/apps.xml">
<subscreens-item name="tutorial" menu-title="Tutorial" menu-index="98" location="component://tutorial/screen/tutorial.xml"/>
</screen>
</screen-facade>
</moqui-conf>
component/tutorial/screen/tutorial.xml
<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-2.1.xsd"
require-authentication="false" include-child-content="true" menu-image="glyphicon glyphicon-wrench" menu-image-type="icon">
<subscreens default-item="hello">
</subscreens>
<widgets>
<label type="h1" text="Hello world with Sub Screens!"/>
<subscreens-panel id="hello-app" type="popup"/>
<subscreens-active/>
</widgets>
</screen>
component/tutorial/screen/tutorial/hello.xml
<screen>
<widgets>
<render-mode>
<text type="html"
location="component://tutorial/screen/tutorial/hello.html"/>
</render-mode>
</widgets>
</screen>
component/tutorial/screen/tutorial/hello.html
<h1>Hello world! (from the hello.html file)</h1>
With the above MoquiConf.xml configuration, the Tutorial component would not even show in the Applications --> AppList (Menu), but works when i load using below change in base-component/webroot/screen/webroot/apps.xml
<subscreens default-item="AppList">
<subscreens-item name="tutorial" menu-title="Tutorial"
location="component://tutorial/screen/tutorial.xml"/>
</subscreens>
Pretty sure i'm missing a config as the above seems to work in example, tools and possibly other components, Appreciate any pointers
Sorry for the delay, i was able to use the online tutorial -> moqui.org/docs/framework/Quick+Tutorial included in David's comments, and was successful in completing the tutorial, Thanks David.

MusicXML-File: WebPermission demand failed for redirect URI

I have a MusicXML-File, beginning with
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0
partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
The file was generated with museScore and seems to be valid XML.
Opening this file in MS VS pro 2013 I get nine errors, among others:
"Fehler bei WebPermission-Anforderung für Umleitungs-URI."
<accidental>sharp</accidental>
<stem>up</stem>
<beam number="1">continue</beam> <---here (line 128)
</note>
<note default-x="265.48" default-y="-65.00" dynamics="92.22">
<pitch>
<step>G</step>
<alter>1</alter>
<octave>3</octave>
</pitch>
<duration>8</duration>
<voice>1</voice>
<type>eighth</type> <---here
<accidental>sharp</accidental>
<stem>up</stem>
<beam number="1">continue</beam>
</note>
<note default-x="303.52" default-y="-60.00" dynamics="84.44">
<pitch>
<step>A</step>
<alter>1</alter>
<octave>3</octave> <--- and here (line 147)
</pitch>
<duration>8</duration>
whereas previous occurences did not bother the compiler.
I have no cue what is the underlying cause for this behavior?
These errors refer actually to the lines in partwise.dtd (thumbs down for VS) and mean that VS failed to access included modules (.mod) due to security policy issues (different zones, etc.).
If you don't want to spend your precious time setting up security stuff, just set up your validation environment to work locally:
Disable the option: Visual Studio > Menu Tools > Options > Text Editor > XML > Miscellaneous > "Automatically download DTDs and schemas".
Download MusicXML Schema (XSD) and extract the whole content to a folder.
Edit the schema, e.g. musicxml.xsd, to import only from local files:
<xs:import (...) schemaLocation="xlink.xsd"/>
<xs:import (...) schemaLocation="xml.xsd"/>
(In this case, both dependencies will be already available in current folder.)
Open your XML file in VS and add the used schema to its properties (details in this answer).
Hint: If you get warnings about attributes being already declared, go to related file, then XML Menu > Schemas and mark double references as not to be used.

How to register a "Linux" file association with autotools

I'm writing an application that uses its own file type. I'd like to integrate the file association with the desktop environment. I know that this can be done with a command, but how should it be integrated with autotools?
Currently, my app can be installed without root to ~/.local for example. It would be nice to keep this feature.
Add a myapp.xml to your project that contains the desired MIME data. It'll look something like:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="image/png">
<comment xml:lang="en">PNG image</comment>
<comment xml:lang="af">png beeld</comment>
...
<magic priority="50">
<match type="string" value="\x89PNG" offset="0"/>
</magic>
<glob pattern="*.png"/>
</mime-type>
</mime-info>
See the tutorial for more details on the format of the XML files.
Now you need to figure out where to install your XML file to. In my projects, I provide a --with-xdgdatadir option to configure, which is left as an exercise to the reader. By default, XDGDATADIR should be ${prefix}/share (i.e. ${datarootdir}). Add the following to your Makefile.am:
xdgdatadir=#XDGDATADIR#
mimedir=$(xdgdatadir)/mime
xmldir=$(mimedir)/packages
xml_DATA = myapp.xml
This will ensure that the MIME data is installed correctly.
Finally, it's necessary to ensure that the MIME database is updated on make install and make uninstall. Add a check for the update-mime-database tool to your configure.ac. Then add the following to your Makefile.am:
install-data-hook:
$(UPDATE_MIME_DATABASE) "$(DESTDIR)$(mimedir)"
uninstall-hook:
$(UPDATE_MIME_DATABASE) "$(DESTDIR)$(mimedir)"
I hope that answers your question.

Include build output as attachment

We have a CruiseControl.NET Server 1.5.0.4401 running. One project uses an external compiler, which is included via exec-task. This compiler is configured to write its output into a textfile that is located in the artifact directory. The filename is keil_Revision-x.txt (x is the revision number) whereas the configuration for this file looks like %ccnetartifactdirectory%\keil_%ccnetlabel%.txt.
We want this output file to be attached to the e-mail report CC is sending for each build. The configuration of the email-publisher is (a bit shortened) the following:
<email from="buildmaster#xxx.yy" mailhost="zzz" mailport="25" includeDetails="TRUE" useSSL="FALSE">
<users>
<!-- Here are some users -->
</users>
<groups>
<!-- Here are some groups -->
</groups>
<converters>
<!-- LDAP converter-->
</converters>
<modifierNotificationTypes>
<!-- Several notification types -->
</modifierNotificationTypes>
<subjectSettings>
<!-- Here are some subject settings -->
</subjectSettings>
<attachments>
<file>${CCNetArtifactDirectory}\keil_${CCNetLabel}.txt</file>
</attachments>
</email>
The only problem is, that the files are not attached. The debug output on the cruise control console doesn't contain any error message. The artifact directory contains all files, only they are not attached. Where is the failure?
Are Integration Properties like CCNetLabel available inside CCNET configuration? I venture to doubt that. Up to CCNET 1.4.4 SP1 they weren't. So please check the attachment node in Your project configuration to see if CCNetLabel has been resolved properly.
You need to define preprocessor constants that can replace the integration properties like this:
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<cb:define project.artifact.dir="C:\foodir" />
<project name="foo">
<artifactDirectory>$(project.artifact.dir)</artifactDirectory>
...
<publishers>
...
<email
from="buildmaster#xxx.yy"
mailhost="zzz"
mailport="25"
includeDetails="TRUE"
useSSL="FALSE">
....
<attachments>
<file>$(project.artifact.dir)\keil.txt</file>
</attachments>
</email>
</publishers>
</project>
</cruisecontrol>
You need to instruct your compiler to write the results to a file whose name is predictable by CCNET configuration. Since configuration has no access to the label it must not be part of the filename. If you want to keep the result files from being overwritten by each build, add an executable task that triggers a simple batch file whose purpose is to copy %ccnetartifactdirectory%\keil.txt to %ccnetartifactdirectory%\keil_%ccnetlabel%.txt.
Otherwise the answer to this question might help here as well.

Resources