Package net.ionite.docval.xml
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>
- 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
- "D16B" if the document is CII
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
- If the document is UBL(2) or CII (D16B), the format is:
-
-
Constructor Summary
Constructors Constructor Description KeywordDeriver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
deriveKeyword(byte[] source)
Derive the keyword from the given InputStreamString
deriveKeyword(InputStream source)
Derive the keyword from the given InputStream
-
-
-
Method Detail
-
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.
-
-