[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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 <Invoice>: 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: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. -- 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] |
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
|