XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Understanding the scope of XML catalog

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
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit.imsieke@le-tex.de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer / Managing Directors:
Gerrit Imsieke, Svea Jelonek, Thomas Schmidt


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS