Define an advanced metadata interceptor to inject model-compliant metadata into your XML content from
property values stored in Alfresco. This metadata will be validated and set accordingly to a user-specified XSD
model to ensure consistency in the XML content.
In the following steps you will be creating and/or configuring Spring beans in a Spring context file. A
basic knowledge of Spring and the Spring Framework is required.
Note: Identifiers and namespaces in the samples below are used as examples. Make sure to replace them with
identifiers and namespaces that match your development guidelines.
-
Open or create a new Spring context file.
-
Create an Advanced XPath Interceptor bean.
-
Use an existing XML schema filter reference
to specify the document types for which the interceptor applies.
-
Define the properties of the bean.
- path
- a bean that defines the xpath and xmlSchema properties:
- xpath
- the XPath of an output node where the injected metadata will be stored
- xmlSchema
- an URI to the XSD model the injected metadata must comply with
- predicate
- Use the fully-qualified name with Clark notation as the value of the predicate.
- xmlSchemaFilter
- the DTD or XSD definition that will be used to filter out the document types for which the
interceptor applies
<bean id="xmlns.rdf.interceptor.fromXsd.bookmap" parent="rdf.interceptor.xpath.advanced.abstract">
<property name="path">
<bean parent="rdf.interceptor.xpath.advanced.pathElementsFromXsd.abstract">
<property name="xpath" value="/bookmap/booktitle/mainbooktitle" />
<property name="xmlSchema" value="urn:oasis:names:tc:dita:xsd:bookmap.xsd" />
</bean>
</property>
<property name="predicate" value="{sample}mainbooktitle" />
<property name="xmlSchemaFilter" ref="dita.schemas.bookMap" />
</bean>
-
Create an Alfresco RDF property interceptor bean.
<bean id="samples.propertyInterceptor.bookmap" parent="alfresco.rdf.propertyInterceptor.abstract">
<property name="property" value="{sample}mainbooktitle" />
</bean>
The Alfresco RDF property interceptor bean will have Componize listen for update events
on the specified properties and react by rewriting the content if needed.
-
Restart the application server for your changes to take effect.
Whenever a property is modified in Alfresco for a document of the specified DTD or XSD, the property value will
be automatically injected into the XML content at the defined XPath location.
Note: The injection occurs asynchronously. All policies and content rules are deactivated on the node during
injection.