[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:29:27 -0500

Re:  Understanding the scope of XML catalog
Thank you!

Your thinking of alternatives also leads me to consider including an NVDL schema in the distribution. Then users can use that one schema to validate any XML document.

A quick search, though, doesn't help me find any examples of command-line NVDL processors that I could include as a JAR file in the UBL distribution. The 20151127 jing that I found appears to take in only an RELAX-NG argument as input.

Thanks, again!

. . . . . Ken

At 2019-03-02 17:20 +0100, Imsieke, Gerrit, le-tex wrote:
Content-Transfer-Encoding: 8bit

Hi Ken,

You might also want to try this pure XSLT solution (using Saxon EE and the same catalog):

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:saxon="http://saxon.sf.net/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="xs saxon"
version="3.0">

<xsl:template match="/*">
<xsl:variable name="schema" as="document-node(element(xs:schema))"
select="doc(namespace-uri())"/>
<xsl:variable name="with-schemaLocation"
as="document-node(element(*))">
<xsl:document>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="xsi:schemaLocation" select="namespace-uri(), base-uri($schema)"/>
<xsl:copy-of select="node()"/>
</xsl:copy>
</xsl:document>
</xsl:variable>
<xsl:message
select="serialize(
saxon:validate($with-schemaLocation),
map{'method': 'adaptive'}
)"/>
</xsl:template>

</xsl:stylesheet>

It loads the schema using the namespace URI of the top-level element (and the catalog mapping to the local file: URI). Then it attaches an xsi:schemaLocation attribute that consists of the namespace URI and the base URI of the local schema document.

$ saxon-EE-9.9.1.1 -xsl:ublval.xsl -s:invoice.xml
map{"valid":false(),"errors":map{"clause":"2.4","path":"/Q{urn:oasis:names:specification:ubl:schema:xsd:Invoice-2}Invoice[1]","colummn":37,"systemId":"","code":Q{http://www.w3.org/2005/xqt-errors}FORG0001,"line":14,"constraint":"cvc-complex-type","message":"In content of element &lt;Invoice&gt;: The content is incomplete. The following elements would be valid here, all in namespace urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2: PaymentExchangeRate, TaxExchangeRate, TaxTotal, PaymentAlternativeExchangeRate, LegalMonetaryTotal, WithholdingTaxTotal, AllowanceCharge, PaymentTerms, PrepaidPayment, PricingExchangeRate. ","specPart":1}}

Gerrit


On 02.03.2019 16:13, Imsieke, Gerrit, le-tex wrote:
On 02.03.2019 15:53, Imsieke, Gerrit, le-tex wrote:
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"
A bit misleading that I still have xsi:schemaLocation here. You can safely omit that attribute and the validation pipeline will still report the same validation errors.
_______________________________________________________________________
XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.
[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
--
Gerrit Imsieke

--
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
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.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.