Is there a way to format multi-valued properties vertically in a Jackrabbit filevault xml doc?

十年热恋 提交于 2019-12-24 07:48:42

问题


We use FileVault xml files in a git repo to configure our custom OSGi services running in our Adobe Experience Manager instance.

This works out really well in many cases, but it seems like we have to list multi-valued properties horizontally, in a comma-only-separated string, like this:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
  jcr:primaryType="sling:OsgiConfig"
  aLongMultiValuedProperty="[first,second,third,fourth,fifth]"/>

This example doesn't look that bad, but I recently edited a file with a line 1998 characters long, and the git diff was incredibly ugly.

So I'd rather be able to format our lists something like this:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
  jcr:primaryType="sling:OsgiConfig"
  aLongMultiValuedProperty="[
    first,
    second,
    third,
    fourth,
    fifth]"/>

However, doing that results in extra whitespace in the JCR property values.

Is there a different vertical formatting that doesn't result in extra whitespace like that?


回答1:


In your situation I would recommend to use the (newer) properties format. With a trailing backslash \ you can specify that a line continued on the next line.

Unfortunately there is little useful documentation in the web. Best do the following XPath query to find some examples:

/jcr:root/apps//*[jcr:like(fn:name(), '%.config')]

Here is a real-world example from me:

com.day.cq.wcm.msm.impl.actions.ContentUpdateActionFactory.config

cq.wcm.msm.action.excludednodetypes=[ \
  "cq:LiveSyncConfig", \
  "cq:BlueprintSyncConfig", \
  "cq:LiveSyncAction", \
  "cq:CatalogSyncConfig", \
  "cq:CatalogSyncAction", \
  "cq:meta", \
  ]
cq.wcm.msm.action.excludedparagraphitems=[ \
  "cq:propertyInheritanceCancelled", \
  ]
cq.wcm.msm.action.excludedprops=[ \
  "jcr:(?!(title|description)$).*", \
  "sling:(?!(resourceType|resourceSuperType)$).*", \
  "cq:(?!(designPath|template|lastTranslationUpdate|targetEngine)$).*", \
  "publishCampaignId", \
  ]
cq.wcm.msm.action.ignoredMixin=[ \
  ".*", \
  ]    

In short it is a property file with the suffix .config. Everything else is just like the sling:OsgiConfig nodes (run-modes, file name). Only be aware that data-types (boolean, long, ...) are specified differently. But you can mix both formats, so you don't have to migrate every config-node.



来源:https://stackoverflow.com/questions/56653251/is-there-a-way-to-format-multi-valued-properties-vertically-in-a-jackrabbit-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!