hello konrad. i've faced the same problem in [1][2] which is using [3] internally. this is the standard list [4] i've come up with - but you have to make it configurable to support custom namespaces. in the plugin, i'm parsing the bundle for Sling-Namespaces headers [5] which usually should contain all custom namespaces used in the JSON of the bundle. of course it may be that namespaces are additionally defined in a cnd file.
stefan [1] https://wcm.io/tooling/maven/plugins/sling-initial-content-transform-maven-plugin/ [2] https://github.com/wcm-io/wcm-io-tooling/tree/develop/maven/plugins/sling-initial-content-transform-maven-plugin [3] https://github.com/wcm-io/wcm-io-tooling/tree/develop/commons/content-package-builder [4] https://github.com/wcm-io/wcm-io-tooling/blob/develop/commons/content-package-builder/src/main/java/io/wcm/tooling/commons/contentpackagebuilder/XmlNamespaces.java [5] https://github.com/wcm-io/wcm-io-tooling/blob/develop/maven/plugins/sling-initial-content-transform-maven-plugin/src/main/java/io/wcm/maven/plugins/slinginitialcontenttransform/OsgiBundleFile.java >-----Original Message----- >From: Konrad Windszus <[email protected]> >Sent: Wednesday, April 14, 2021 6:35 PM >To: [email protected] >Subject: o.a.s.contentparser.api.ContentHandler: Namespace handling > >Hi, >in the context of https://issues.apache.org/jira/browse/SLING-10243 I am >currently trying to convert JSON Descriptor Files >(https://sling.apache.org/documentation/bundles/content-loading-jcr- >contentloader.html#json-descriptor-files) to Enhanced Docview XML >(http://jackrabbit.apache.org/filevault/docview.html). > >I want to leverage https://github.com/apache/sling-org-apache-sling- >contentparser-api for parsing the JSON Descriptor Files and I am wondering >how to best deal with namespaces. >Neither https://github.com/apache/sling-org-apache-sling-contentparser- >api/blob/master/src/main/java/org/apache/sling/contentparser/api/ContentHan >dler.java nor https://sling.apache.org/documentation/bundles/content- >loading-jcr-contentloader.html#json-descriptor-files mentions namespaces >but the example uses certain namespace prefixes. > >It doesn't seem mandatory though to define the used prefixes in the Sling- >Nodetypes bundle header, so do we just assume that all repositories use the >same prefixes? >IMHO only namespace URI are globally unique but not necessarily the >namespace prefixes. >JCR itself only defines 4 prefixes: >https://docs.adobe.com/content/docs/en/spec/jcr/2.0/3_Repository_Model.html >#3.5.1%20Namespace%20Registry > >As (DocView) XML requires to explicitly declare the used namespaces I >wonder which table to use as basis? >Should I just take the mapping from the Sling Starter? > >Thanks for any input, >Konrad
