问题
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