Added by Jasha Joachimsthal, last edited by Jasha Joachimsthal on Jul 02, 2008
()
If your document contains elements with namespaces other than the default namespace, your property may be empty. The solution to this depends on the extractor and on how you can control the content of your document.
Using a namespace prefix
This solution can be used in when the following conditions are met:
- The extractor is org.apache.slide.extractor.SimpleXmlExtractor or nl.hippo.slide.extractor.HippoSimpleXmlExtractor
- All namespaces are declared with a prefix on the root node of a document
- The name of the prefix is used in the xpath of the extractor
In case of implicit namespaces: - The URI of the explicit namespace in the root node must match the URI of an implicit namespace in your xpath
XML fragment
<foo xmlns:bar="http://acme.com/bar"> <bar xmlns="http://acme.com/bar">Temple</bar> <baz>Bazz</baz> </foo>
Extractor configuration
<extractor classname="nl.hippo.slide.extractor.HippoSimpleXmlExtractor" uri="/files/default.preview/content" content-type="text/xml"> <configuration> <instruction property="bar" namespace="http://hippo.nl/cms/1.0" xpath="/foo/bar:bar/text()"/> </configuration> </extractor>
Using local-name() in xpaths
XML Fragment
<foo> <bars xmlns="http://acme.com/bar"> <bar>Temple</bar> <bar>Foobar</bar> </bars> </foo>
Extractor configuration
<extractor classname="nl.hippo.slide.extractor.MultiValueXMLPropertyExtractor" uri="/files/default.preview/content" content-type="text/xml"> <configuration> <instruction property="bars" namespace="http://hippo.nl/cms/1.0" xpath="/foo/node()[local-name()='bars']/node()[local-name()='bar']/text()"/> </configuration> </extractor>