[XML-DEV Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Understanding the scope of XML catalog
- From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
- To: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@le-tex.de>,xml-dev@l...
- Date: Sat, 02 Mar 2019 11:18:55 -0500
Thank you, very kindly, Gerrit, for this detailed example!
. . . . . Ken
At 2019-03-02 15:53 +0100, Imsieke, Gerrit, le-tex wrote:
Content-Transfer-Encoding: 8bit
On 02.03.2019 14:38, G. Ken Holman wrote:
I wonder if Norm could be convinced to consider broadening the
scope in a new XML Catalog 1.2?
But even if he conceived such a namespace URI to schema location
mapping, validating parsers still need to be instructed to use the mapping.
But since you mention Norm: He happens to be the editor of the XProc
specs and the author of the XProc processor XML Calabash.
With the catalog entry that you suggested, and with a small XProc
pipeline, we can actually resolve the namespace URI of the top-level
UBL document element to the corresponding schema!
This goes into the catalog that Calabash uses:
<uri name="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
uri="../maindoc/UBL-Invoice-2.2.xsd"/>
The XML catalog is in the file xmlcatalog/catalog.xml, which is
supplied to Calabash as seen in this front-end bash script for
invoking Calabash:
https://github.com/transpect/calabash-frontend/blob/master/calabash.sh
In addition to the invoice schema in maindoc/, there is a mirror of
the https://docs.oasis-open.org/ubl/os-UBL-2.2/xsd/common/ directory
alongside maindoc/
This is ublval.xpl:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0">
<p:input port="source" sequence="true" primary="true"/>
<p:output port="result" sequence="true" primary="true"/>
<p:for-each name="validation-iteration">
<p:load name="load-schema">
<p:with-option name="href" select="namespace-uri(/*)"/>
</p:load>
<p:sink/>
<p:validate-with-xml-schema assert-valid="true">
<p:input port="source">
<p:pipe port="current" step="validation-iteration"/>
</p:input>
<p:input port="schema">
<p:pipe port="result" step="load-schema"/>
</p:input>
</p:validate-with-xml-schema>
</p:for-each>
</p:declare-step>
This is an input document:
<Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2
../maindoc/UBL-Invoice-2.2.xsd"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
<cbc:UBLVersionID>2.2</cbc:UBLVersionID>
<cbc:ID>TOSL108</cbc:ID>
<cbc:IssueDate>2009-12-15</cbc:IssueDate>
<cac:AccountingSupplierParty/>
<cac:AccountingCustomerParty/>
<cac:PayeeParty/>
<cac:BuyerCustomerParty/>
<cac:SellerSupplierParty/>
<cac:TaxRepresentativeParty/>
<cac:Delivery/>
<cac:DeliveryTerms/>
<cac:PaymentMeans>
<cbc:PaymentMeansCode/>
</cac:PaymentMeans>
<cac:PaymentTerms/>
</Invoice>
This is the XML Calabash invocation (using the front-end bash script
linked above):
calabash/calabash.sh -i source=invoice.xml ublval.xpl
This is the result:
ERROR: err:XC0053:XProc error err:XC0053
ERROR: cause: cvc-complex-type.2.4.b: The content of element
'Invoice' is not complete. One of
'{"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":PaymentTerms,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":PrepaidPayment,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":AllowanceCharge,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":TaxExchangeRate,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":PricingExchangeRate,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":PaymentExchangeRate,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":PaymentAlternativeExchangeRate,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":TaxTotal,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":WithholdingTaxTotal,
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2":LegalMonetaryTotal}'
is expected.
ERROR: It is a dynamic error if the assert-valid option is true and
the input document is not valid.
If you don't want the XML validation to fail but to issue a report,
you can use p:try/p:catch. I can send you a more elaborate pipeline
if you like.
The main trick is: In XProc, but also in other scripting languages
that provide the XPath function namespace-uri(), you can read the
namespace URI of the top-level element and, thanks to the catalog,
resolve it immeadiately to a local copy of your schema.
You are welcome.
Gerrit
--
Contact info, blog, articles, etc. http://www.CraneSoftwrights.com/x/ |
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Streaming hands-on XSLT/XPath 2 training class @ US$45 (5 hours free) |
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|
Stylus Studio has published XML-DEV in RSS and ATOM formats,
enabling users to easily subcribe to the list from their preferred news reader application.
|
Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website.
they were not included by the author in the initial post. To view the content without the Sponsor Links please
click here.
|
|