Copyright © 2013 Crane Softwrights Ltd.
$Date: 2013/04/16 00:40:23 $(UTC)
Table of Contents
The OASIS Code List Representation Technical Committee [CLRTC] has created the Context/value association (CVA) file format [CVA] where partners in information interchange can associate the values found in genericode [genericode] files with information items found in XML documents of any vocabulary. For example, the Universal Business Language [UBL 2.0] defines a vocabulary for business documents and a two-phase validation process in which the structural and lexical validation is achieved using W3C Schema [W3C Schema], and value validation using a methodology based on CVA files using XSLT 1.0 [XSLT 1.0].
Crane Softwrights Ltd. has developed the following three XSLT 1.0
stylesheets used for the rendering of either standalone genericode files
or context/value association files that reference genericode files.
These stylesheets recognize elements in the XHTML namespace
("http://www.w3.org/1999/xhtml
") or HTML 4 namespace
("http://www.w3.org/TR/REC-html40
") and produce a
report with constructs in the XHTML namespace.
The stylesheet to render a genericode file is named "Crane-gc2html.xsl
".
The simplified stylesheet to render a context/value association file is
named "Crane-cva2html.xsl
" (does not include instance
metadata summaries for each referenced list). A more detailed stylesheet
to render a context/value association file is named
Crane-cva2htmlXSLT.xsl
(includes instance metadata
summaries for each referenced list) and requires a more detailed process
to render the results than that of the simplified stylesheet.
It is not necessary for any referenced genericode files to be processed with a stylesheet when using a stylesheet to view a context/value association file. It is only necessary to use a stylesheet with a genericode file when wanting to view the genericode file in isolation.
The renderings are simplified presentations of the information found in these files. Where it makes sense there are hyperlinks pointing elsewhere in the document to definitions of the information referenced.
The specification and document constraints for context/association files allow for embedded use of elements from a foreign namespace, in addition to text documentation. The stylesheet in this package assumes that the embedded documentation is wrapped in HTML constructs using the http://www.w3.org/TR/REC-html40
namespace.
The documentation for the value validation methodology includes the file order-constraints.cva
. This stylesheet package includes a modified version of that file, named order-constraints-doc.cva
, in which the documentation constructs are wrapped in HTML vocabulary:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="Crane-cva2html.xsl"?> <cva:ContextValueAssociation xmlns:cva= "http://docs.oasis-open.org/codelist/ns/ContextValueAssociation/1.0/" xmlns:cbc="urn:oasis:names:draft:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:draft:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:x="http://www.w3.org/TR/REC-html40" xmlns:sch="http://purl.oclc.org/dsdl/schematron" id="urn:x-illustration" name="code-list-rules" version= "$Id: readme-Crane-cva-gc-xsl.xml,v 1.47 2013/04/16 00:40:23 admin Exp $"> <Annotation> <Description> <x:p> This is an illustrative example of all of the features of specifying the context/value constraints that one can express for XML documents. </x:p> <x:p> The validation requirements for this contrived scenario are as follows: <x:ul> <x:li>the UN/CEFACT currency code list is restricted to be only Canadian and US dollars:</x:li> <x:li>the seller must be in the US</x:li> <x:li>the buyer may be in either Canada or the US</x:li> <x:li>the definition for Payment Means is extended to include both UBL definitions and additional definitions</x:li> </x:ul> </x:p> </Description> </Annotation> <Title> Illustration of code list constraints - <x:samp>order-constraints.cva</x:samp> </Title> <!--list all test expressions--> <ValueTests> <ValueTest xml:id="length-35" test="string-length(.)<=35"> <Annotation> <Description> <x:p>Certain fields are restricted to 35 characters in length.</x:p> </Description> </Annotation> </ValueTest> </ValueTests> <!--list all of the genericode expressions of agreed-upon code list value enumerations--> <ValueLists> <ValueList xml:id="currency" uri="CAUS_CurrencyCode.gc" masqueradeUri="UBL_CurrencyCode-2.0.gc"> <Annotation> <Description> <x:p>Restricted to only Canadian and US dollars.</x:p> </Description> </Annotation> <Identification> <LongName>ISO Currency List</LongName> </Identification> </ValueList> <ValueList xml:id="states" uri="US_CountrySubentityCode.gc"> <Annotation> <Description> <x:p>List of US states.</x:p> </Description> </Annotation> </ValueList> <ValueList xml:id="provinces" uri="CA_CountrySubentityCode.gc"> <Annotation> <Description> <x:p>List of Canadian provinces</x:p> </Description> </Annotation> </ValueList> <ValueList xml:id="tax-ids" uri="TaxIdentifier.gc" key="codeKey"> <Annotation> <Description> <x:p>List of tax type identifiers</x:p> </Description> </Annotation> </ValueList> <ValueList xml:id="payments" uri="UBL_PaymentMeansCode-2.0.gc"> <Annotation> <Description> <x:p> Copied from the UBL 2.0 suite: <x:a href="http://docs.oasis-open.org/ubl/cs-UBL-2.0/"> <x:samp>http://docs.oasis-open.org/ubl/cs-UBL-2.0/</x:samp> </x:a> </x:p> </Description> </Annotation> </ValueList> <ValueList xml:id="additional_payments" uri="Additional_PaymentMeansCode.gc"> <Annotation> <Description> <x:p>An extra set of possible payment means.</x:p> </Description> </Annotation> </ValueList> </ValueLists> <!--list all of the instance-level metadata components associated with genericode <Identification> components--> <InstanceMetadataSets> <Annotation> <Description> <x:p>UN/CEFACT CCTS V2.01 supplementary components to genericode</x:p> </Description> </Annotation> <InstanceMetadataSet xml:id="cctsV2.01-amount"> <Annotation> <Description> <x:p>CCTS 2.01 AmountType instance metadata</x:p> </Description> </Annotation> <InstanceMetadata address="../@currencyCodeListVersionID" identification="Version"/> </InstanceMetadataSet> <InstanceMetadataSet xml:id="cctsV2.01-measure"> <Annotation> <Description> <x:p>CCTS 2.01 MeasureType instance metadata</x:p> </Description> </Annotation> <InstanceMetadata address="../@unitCodeListVersionID" identification="Version"/> </InstanceMetadataSet> <InstanceMetadataSet xml:id="cctsV2.01-quantity"> <Annotation> <Description> <x:p>CCTS 2.01 QuantityType instance metadata</x:p> </Description> </Annotation> <InstanceMetadata address="../@unitCodeListID" identification="Version"/> <InstanceMetadata address="../@unitCodeListAgencyName" identification="Agency/LongName"/> <InstanceMetadata address="../@unitCodeListAgencyID" identification="Agency/Identifier"/> </InstanceMetadataSet> <InstanceMetadataSet xml:id="cctsV2.01-code"> <Annotation> <Description> <x:p>CCTS 2.01 CodeType instance metadata</x:p> </Description> </Annotation> <InstanceMetadata address="@listName" identification="LongName[not(@Identifier='listID')]"/> <InstanceMetadata address="@listID" identification="LongName[@Identifier='listID']"/> <InstanceMetadata address="@listVersionID" identification="Version"/> <InstanceMetadata address="@listSchemeURI" identification="CanonicalUri"/> <InstanceMetadata address="@listURI" identification="LocationUri"/> <InstanceMetadata address="@listAgencyName" identification="Agency/LongName"/> <InstanceMetadata address="@listAgencyID" identification="Agency/Identifier"/> </InstanceMetadataSet> <InstanceMetadataSet xml:id="cctsV2.01-identifier"> <Annotation> <Description> <x:p>CCTS 2.01 IdentifierType instance metadata</x:p> </Description> </Annotation> <InstanceMetadata address="@schemeName" identification="LongName[not(@Identifier='listID')]"/> <InstanceMetadata address="@schemeID" identification="LongName[@Identifier='listID']"/> <InstanceMetadata address="@schemeVersionID" identification="Version"/> <InstanceMetadata address="@schemeURI" identification="CanonicalUri"/> <InstanceMetadata address="@schemeDataURI" identification="LocationUri"/> <InstanceMetadata address="@schemeAgencyName" identification="Agency/LongName"/> <InstanceMetadata address="@schemeAgencyID" identification="Agency/Identifier"/> </InstanceMetadataSet> </InstanceMetadataSets> <!--list all of the contexts in which the value enumerations are used; where two or more contexts might match a given node in the input, list them here in order of most-important to least important match--> <Contexts> <Context address="@currencyID" values="currency" mark="money" metadata="cctsV2.01-amount"> <Annotation> <Description> <x:p>All currencies are restricted to only Canadian and US dollars.</x:p> </Description> </Annotation> </Context> <Context address="cac:BuyerCustomerParty//cbc:CountrySubentityCode" values="provinces states" metadata="cctsV2.01-code"> <Annotation> <Description> <x:p>The buyer can be in either Canada or the US.</x:p> </Description> </Annotation> <Message>Invalid province or state '<sch:value-of select="."/>' for buyer "<sch:value-of select="ancestor::cac:BuyerCustomerParty/cac:Party/cac:PartyName/cbc:Name"/>"</Message> </Context> <Context address="cac:SellerSupplierParty//cbc:CountrySubentityCode" values="states" metadata="cctsV2.01-code"> <Annotation> <Description> <x:p>The seller can only be in the US.</x:p> </Description> </Annotation> <Message>Invalid state '<sch:value-of select="."/>' for seller "<sch:value-of select="ancestor::cac:SellerSupplierParty/cac:Party/cac:PartyName/cbc:Name"/>"</Message> </Context> <Context address="cac:TaxCategory/cbc:ID" values="tax-ids" mark="money" metadata="cctsV2.01-identifier"> <Annotation> <Description> <x:p>Limit the recognized tax identifiers</x:p> </Description> </Annotation> </Context> <Context address="cbc:PaymentMeansCode" mark="money" values="payments additional_payments" metadata="cctsV2.01-code"> <Annotation> <Description> <x:p>The payments can be by either standard or supplemental means.</x:p> </Description> </Annotation> </Context> <Context address="cbc:Name" values="length-35"> <Annotation> <Description> <x:p>Names are not allowed to be too long.</x:p> </Description> </Annotation> </Context> <Context address="cbc:StreetName" values="length-35"> <Annotation> <Description> <x:p>Addresses are not allowed to be too long.</x:p> </Description> </Annotation> </Context> </Contexts> </cva:ContextValueAssociation>
Note throughout the embedded documentation the use of a namespace prefix (in this example "x
") to reference the HTML vocabulary ("http://www.w3.org/TR/REC-html40
").
It is possible to view either a genericode file or a context/value association file directly in a browser by embedding a stylesheet association [Assoc] processing instruction. If the stylesheet is in the same directory as the genericode file, then the following would be added to the genericode file, immediately after the XML declaration at the top of the file (as in the testRender.gc
sample file):
<?xml-stylesheet type="text/xsl" href="Crane-gc2html.xsl"?>
Similarly for a context/value association file, the following processing instruction would be used (as in the order-constraints-doc.cva
sample file):
<?xml-stylesheet type="text/xsl" href="Crane-cva2html.xsl"?>
The Crane-cva2htmlXSLT.xsl
stylesheet cannot be
used in the browser with standalone stylesheet association. See Section 4, “ Standalone HTML creation” for details.
Of course if the stylesheets are in a different directory than the files using them, the href=
attribute needs to point to the correct path to the stylesheet.
When embedding references to stylesheets in a CVA file it is not necessary to also add them to the referenced genericode files as the CVA stylesheet will trigger the genericode stylesheet for each genericode reference it finds.
When in a Windows interface, drag the genericode file from the Windows Explorer to Mozilla Firefox or Internet Explorer to engage the stylesheet presentation.
For operation in Internet Explorer it is necessary in Windows XP to
indicate that ".gc
" files are XML documents. This is
done in Windows Explorer under the
Tools/FolderOptions...
menu, under the File Types
tab, clicking the "New
" button, setting the File
Extension to "gc
", then clicking the
"Advanced
" button to set the Associated File Type
to "XML Document
". Using the
"Change
" button next to the "Opens
with:
" herald, one can then set the recommended program to
be Internet Explorer. For Windows 7 go to the Control Panel and in the
"Default Programs" section associate a program for the file
type.
When using earlier versions of Internet Explorer to directly view either a genericode or a context/value association XML file, the back button incorrectly refreshes the screen and positions the active point at the top of the file. This appears not to be a problem with later versions.
When creating standalone HTML from the XML of a genericode file, two examples of using Saxon [Saxon] are as follows, the first explicitly referencing the stylesheet and the second looking for the embedded stylesheet association:
java -jar saxon.jar -o file.html file.gc Crane-gc2html.xsl
and
java -jar saxon.jar -o file.html -a file.gc
When creating standalone HTML from the XML of a context/value association file with the simplified CVA stylesheet, two examples of using Saxon are as follows, the first explicitly referencing the stylesheet and the second looking for the embedded stylesheet association:
java -jar saxon.jar -o file.html file.cva Crane-cva2html.xsl
and
java -jar saxon.jar -o file.html -a file.cva
When creating standalone HTML from the XML of a context/value
association file with the more detailed CVA stylesheet
Crane-cva2htmlXSLT.xsl
, the following two steps must
be taken, in order, to produce the result:
java -jar saxon.jar -o intermediateFileAnywhere.xsl file.cva Crane-cva2htmlXSLT.xsl java -jar saxon.jar -o file.html intermediateFileAnywhere.xsl intermediateFileAnywhere.xsl
This two-step processing model required for
Crane-cva2htmlXSLT.xsl
prevents its operation in a
web browser, as browsers only support the single application of one
XSLT stylesheet against an input XML file.
The stylesheets are structured such that the built-in textual messages can be overridden with a importing stylesheet. The included stylesheet Crane-alternate-cva2html.xsl
illustrates how this overriding can be done, and would be invoked in the following manner, the first explicitly referencing the stylesheet and the second looking for the embedded stylesheet association:
java -jar saxon.jar -o file.html file.cva Crane-alternate-cva2html.xsl
or
java -jar saxon.jar -o file.html -a file.cva
Both Crane-cva2html.xsl
and Crane-gc2html.xsl
have all built-in messages written in English and can have these messages overridden using the method illustrated in Crane-alternate-cva2html.xsl
. When declaring the overriding variables and template, be sure to use the corresponding namespace qualification on the name of the top-level construct.
To utilize the overriding stylesheet with the more detailed CVA
reporting process, copy Crane-cva2htmlXSLT.xsl
and
modify the copy to import the overriding stylesheet. The two-step
process is identical, only using the newly-created stylesheet in the
first step.
The stylesheets are structured such that a wrapper stylesheet can define content for the HTML header element that is output. This is particularly handy to add embedded CSS styles in the HTML header.
The two example wrapper stylesheets
Crane-head-gc2html.xsl
and
Crane-head-cva2html.xsl
illustrate this technique.
These stylesheets colour the background, respectively, green and
blue.
Invoking the stylesheet for a genericode file is done along the lines of one of the following:
java -jar saxon.jar -o file.html file.gc Crane-head-gc2html.xsl
or
java -jar saxon.jar -o file.html -a file.gc
Invoking the stylesheet for a CVA file is done along the lines of the following:
java -jar saxon.jar -o file.html file.cva Crane-head-cva2html.xsl
or
java -jar saxon.jar -o file.html -a file.cva
To utilize the augmenting stylesheet with the more detailed CVA
reporting process, copy Crane-cva2htmlXSLT.xsl
and
modify the copy to import the augmenting stylesheet. The two-step
process is identical, only using the newly-created stylesheet in the
first step.
The following sample files included in the ZIP package in which this documentation is obtained:
Additional_PaymentMeansCode.gc
an example file extracted from the validation demonstration scenario
CAUS_CurrencyCode.gc
an example file extracted from the validation demonstration scenario
CA_CountrySubentityCode.gc
an example file extracted from the validation demonstration scenario
Crane-alternate-cva2html.xsl
an illustration of importing the stylesheet for a context/value association file where some of the built-in messages are overridden
Crane-cva2html.xsl
the stylesheet used to render a context/value association file in HTML with the simplified presentation (no instance metadata summaries for each referenced list)
this stylesheet makes reference to the
Crane-gc2html.xsl
stylesheet
Crane-cva2htmlXSLT.xsl
the stylesheet used to render a context/value association file in HTML with the detailed presentation including instance metadata summaries for each referenced list
this stylesheet makes reference to the
Crane-cva2html.xsl
stylesheet
Crane-gc2html.xsl
the stylesheet used to render a genericode file in HTML
Crane-head-cva2html.xsl
an illustration of importing the stylesheet for a context/value association file where the output HTML head element is augmented with style information
Crane-head-gc2html.xsl
an illustration of importing the stylesheet for a context/value association file where the output HTML head element is augmented with style information
order-constraints-doc.cva
a modified version of the example
order-constraints.cva
example file in the
validation demonstration scenario
all that has been changed is that the documentation previously found in clear text is now wrapped in HTML markup, and there is a stylesheet association processing instruction near the top of the file
note that because of the stylesheet association this file can be dragged into a browser to trigger the presentation automatically
TaxIdentifier.gc
an example file extracted from the validation demonstration scenario
testRender.gc
an example of the standalone rendering of a genericode file in which a stylesheet association has been placed
note that because of the stylesheet association this file can be dragged into a browser to trigger the presentation automatically
UBL_CurrencyCode-2.0.gc
an example file extracted from the validation demonstration scenario
UBL_PaymentMeansCode-2.0.gc
an example file extracted from the validation demonstration scenario
US_CountrySubentityCode.gc
an example file extracted from the validation demonstration scenario
At this time the rendering of a context/value association file that includes other context/value association files will result in the duplicate rendering of a given genericode that is referenced from more than one context/value association file. This does not happen often, and it is not an error, but the end result will have as many renderings of a given genericode file as there are value list declarations for that file in the complete "include set" of context/association files. A future version of these stylesheets could detect the redundant renderings of a given genericode file.
2013-04-16 - Crane-cva2html.xsl
revision 1.32;
Crane-cva2htmlXSLT.xsl
revision 1.2;
Crane-gc2html.xsl
revision 1.17
add the detailed presentation stylesheet Crane-cva2htmlXSLT.xsl
2011-11-13 - Crane-cva2html.xsl
revision 1.30;
Crane-gc2html.xsl
revision 1.17
add rudimentary support for code list sets in genericode files
make location URIs hot links
add list long name to title when genericode stylesheet invoked standalone
2010-04-14 - Crane-cva2html.xsl
revision 1.30;
Crane-gc2html.xsl
revision 1.16
repair detection of HTML/XHTML
output in XHTML
support augmented HTML headers for styling
2010-03-10 - Crane-cva2html.xsl
revision 1.29;
Crane-gc2html.xsl
revision 1.15
expose the existence of overriding metadata when pointing to a value list
2010-01-31 - Crane-cva2html.xsl
revision 1.28; Crane-gc2html.xsl
revision 1.15
documentation bibliography only; no code changes
2010-01-20 - Crane-cva2html.xsl
revision 1.28; Crane-gc2html.xsl
revision 1.15
change in the document element name for CVA files
change in the documentation bibliography
2009-10-08 - Crane-cva2html.xsl
revision 1.26; Crane-gc2html.xsl
revision 1.15
documentation bibliography only; no code changes
2009-09-13 - Crane-cva2html.xsl
revision 1.26; Crane-gc2html.xsl
revision 1.15
namespace
2009-08-26 - Crane-cva2html.xsl
revision 1.24; Crane-gc2html.xsl
revision 1.15
handle absent columns in rows
handle unlabeled columns in rows
2009-07-21 - Crane-cva2html.xsl
revision 1.24; Crane-gc2html.xsl
revision 1.13
left-align genericode columns and parameterize for those who like otherwise
2009-07-17 - Crane-cva2html.xsl
revision 1.24; Crane-gc2html.xsl
revision 1.12
add a table of contents
support two namespaces for incoming HTML vocabularies ("http://www.w3.org/TR/REC-html40
" and
"http://www.w3.org/1999/xhtml
")
add shortcut hyperlink to value list detail in the context reporting
2009-07-12 - Crane-cva2html.xsl
revision 1.23; Crane-gc2html.xsl
revision 1.12
support CVA 0.7 Draft 2 in CVA files
2009-07-07 - Crane-cva2html.xsl
revision 1.22; Crane-gc2html.xsl
revision 1.11
support CVA 0.7 Draft 1 in CVA files
2009-05-23 - Crane-cva2html.xsl
revision 1.20; Crane-gc2html.xsl
revision 1.11
support CVA 0.6 Draft 1 in CVA files
repair reporting of genericode files from included CVA files
rename stylesheets with shorter names
2008-11-11 - Crane-assoc2html.xsl
revision 1.16; Crane-genericode2html.xsl
revision 1.10
support mark=
in CVA files
2008-03-06 - Crane-assoc2html.xsl
revision 1.15; Crane-genericode2html.xsl
revision 1.10
support annotation documentation in genericode files
2008-03-04 - Crane-assoc2html.xsl
revision 1.15; Crane-genericode2html.xsl
revision 1.9
changed item names according to CVA 0.3 Draft 1
2007-11-21 - Crane-assoc2html.xsl
revision 1.14; Crane-genericode2html.xsl
revision 1.9
changed association namespace URI to draft status per CLRTC meeting
2007-10-28 - Crane-assoc2html.xsl
revision 1.13; Crane-genericode2html.xsl
revision 1.9
citations of revised OASIS specifications
report nested masquerading meta data
2007-07-28 - Crane-assoc2html.xsl
revision 1.12; Crane-genericode2html.xsl
revision 1.8
new namespaces for genericode and context/value association files
changed citations in bibliography
2007-04-22 - Crane-assoc2html.xsl
revision 1.11; Crane-genericode2html.xsl
revision 1.7
repair wording of "value list" in list of document contexts
reflect stylesheet version in report meta data at the end of the report
[Assoc] James Clark Associating Style Sheets with XML documents Version 1.0 1999-06-29
[genericode] OASIS Genericode 1.0
[Saxon] Michael Kay Saxon
[UBL 2.0] Jon Bosak, Tim McGrath, G. Ken Holman Universal Business Language (UBL) Version 2.0, OASIS UBL Technical Committee 2006
[W3C Schema] XML Schema Part 0: Primer, XML Schema Part 1: Structures, XML Schema Part 2: Datatypes 2004-10-28
[XSLT 1.0] James Clark XSL Transformations (XSLT) Version 1.0 1999-11-16