Re: [xml-dev] Understanding the scope of XML catalog

From
G. Ken Holman <>
To
"Imsieke, Gerrit, le-tex" <>,
Date
2019-03-02T16:29:27Z
ID
<>
Thread
Re: [xml-dev] 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: 
>>subscribe: 
>>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) |