Class KeywordDeriver

java.lang.Object
net.ionite.docval.xml.KeywordDeriver

public class KeywordDeriver extends Object
Derives a keyword from a given XML file.

This can be used instead of manually setting and using your own keywords for each document type. The derived value matches the way document ids are used in the Peppol SBDH, i.e. using the document identifier scheme busdox-docid-qns with a subtype based on the customization id and UBL version.

The derivation works as follows:

  • If the document is UBL(2) or CII (D16B), the format is:
     <namespace>::<root element>##<document type>::<document type version>
     
  • For any other XML document with a namespace, the format is:
     <namespace>::<root element>
     
  • For any other XML document without a namespace, it is simply the root element name:
     <root element>
     
The individual values are as follows:
  • namespace: The XML namespace of the XML document
  • root element: The tag name of the root element of the XML document
  • document type: either:
    • The value of the CustomizationID element, if the document is UBL
    • The value of <ReusableAggregateBusinessInformationEntity/ID>, if the document is CII
  • version, either:
    • The value of the UBLVersionID Element, if the document is UBL
    • "2.1" if the document is UBL (2), and no UBLVersionID element is present, unless it's one of the specific Logistics documents in this list
    • "D16B" if the document is CII
    • "1.0" if the document is a Peppol Transaction Statistics Report
    • "1.1" if the document is a Peppol End User Statistics Report
    • "2.3" if the document is a Peppol Logistics Receipt Advice
    • "2.3" if the document is a Peppol Logistics Weight Statement
    • "2.3" if the document is a Peppol Logistics Transport Execution Plan Request
    • "2.3" if the document is a Peppol Logistics Transport Execution Plan
    • "2.3" if the document is a Peppol Logistics Waybill
    • "2.3" if the document is a Peppol Logistics Transportation Status Request
    • "2.3" if the document is a Peppol Logistics Transportation Status
These last ones are because the files themselves do not contain this information, and the specifications do state it should be these values. For example, a Peppol BIS 3 UBL Invoice document would have the following derived keyword:
 urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0::2.1
 
But a plain XML document, without a namespace, such as: <FooBar><Baz /></FooBar> would have the keyword:
 FooBar
 

You can use the ion-docval-cli tool to generate a derived keyword for any given XML file (API: CommandLineValidator).

Author:
Ionite
  • Constructor Details

    • KeywordDeriver

      public KeywordDeriver()
  • Method Details

    • deriveKeyword

      public String deriveKeyword(byte[] source)
      Derive the keyword from the given InputStream
      Parameters:
      source - The XML source to derive the keyword from
      Returns:
      a String with the keyword.
    • deriveKeyword

      public String deriveKeyword(InputStream source)
      Derive the keyword from the given InputStream
      Parameters:
      source - The XML source to derive the keyword from
      Returns:
      a String with the keyword.