AnsweredAssumed Answered

Help needed on XPathMetadataExtracter

Question asked by tamilraj2003 on Feb 12, 2008
I am having following XML content file in one of the web projects inside alfrescco

<fs:fashion>
<fs:brand>
<fs:name>Prada</fs:name>
<fs:category>
<fs:name>Eyeglasses</fs:name>
<fs:product>
<fs:modelName xsi:nil="false">Sharp</fs:modelName>
<fs:color xsi:nil="false">Black</fs:color>
<fs:price xsi:nil="false">$700</fs:price>
<fs:image xsi:nil="false">/images/model3.jpg</fs:image>
<fs:comments xsi:nil="false">Wear  it !!!</fs:comments>
</fs:product>
</fs:category>
</fs:brand>
</fs:fashion>

In order to extract the some content values into metadata, I did define the following context files

created a custom-repository-context.xml and placed in <TOMCAT>\webapps\alfresco\WEB-INF\classes\extension folder with following content

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
 
   <!– An extractor that operates on Fashion project files –>
   <bean id="extracter.xml.FashionMetadataExtracter"
         class="org.alfresco.repo.content.metadata.xml.XPathMetadataExtracter"
         parent="baseMetadataExtracter"
         init-method="init" >
      <property name="mappingProperties">
         <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="location">
               <value>classpath:fashion/xml-metadata/fashion-metadata-mappings.properties</value>
            </property>
         </bean>
      </property>
      <property name="xpathMappingProperties">
         <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <property name="location">
               <value>classpath:fashion/xml-metadata/fashion-metadata-xpath-mappings.properties</value>
            </property>
         </bean>
      </property>
   </bean>
  
   <!– A selector that checks root element names –>
   <bean
         id="extracter.xml.selector.RootElementSelector"
         class="org.alfresco.repo.content.selector.RootElementNameContentWorkerSelector"
         init-method="init">
      <property name="workers">
         <map>
            <entry key="fs:fashion">
               <ref bean="extracter.xml.FashionMetadataExtracter" />
            </entry>
         </map>
      </property>
   </bean>
  
   <!– A selector that executes XPath statements –>
   <bean
         id="extracter.xml.selector.XPathSelector"
         class="org.alfresco.repo.content.selector.XPathContentWorkerSelector"
         init-method="init">
      <property name="workers">
         <map>
            <entry key="/fs:fashion">
               <ref bean="extracter.xml.FashionMetadataExtracter" />
            </entry>
         </map>
      </property>
   </bean>
  
   <!– The wrapper XML metadata extracter –>
   <bean
         id="extracter.xml.XMLMetadataExtracter"
         class="org.alfresco.repo.content.metadata.xml.XmlMetadataExtracter"
         parent="baseMetadataExtracter">
      <property name="overwritePolicy">
         <value>EAGER</value>
      </property>
      <property name="selectors">
         <list>
            <ref bean="extracter.xml.selector.XPathSelector" />
         </list>
      </property>
   </bean>
</beans>  

The two property files referred are as follows (available in class path)

fashion-metadata-mappings.properties
##################
namespace.prefix.cm=http://www.alfresco.org/model/content/1.0
brandName=cm:brand
category=cm:category
price=cm:price
color=cm:color
##################
fashion-metadata-xpath-mappings.properties
#####################
namespace.prefix.fs="http://www.icrossing.com/fashion/Fashion

brandName=/fashion/brand/name/text()
category=/fashion/brand/category/name/text()
price=/fashion/brand/category/product/price/text()
color=/fashion/brand/category/product/color/text()
#############


When I change the content in the XML file, the metadata extractor is not working as expected, because  I had the debug statements in the eclipse SVN source on the XPathMetadataExtracter methods, which are not called.

Am I missing something? Can anybody help me to resolve this issue, so that I can start extracting the metadata from my content XMLs?

Thanks in advance!

regards
Selva

Outcomes