I've tried the SimpleXMLExtractor, but that didn't work.
After that, I changed the HippoXMLExtractor (see diff.txt). This worked fine,
but isn't very neat.
Current extractor config:
<?xml version="1.0"?>
<extractors>
<extractor classname="nl.hippo.slide.extractor.HippoSimpleXmlExtractor"
uri="/files/default.preview/content"
content-type="text/xml | application/xml | text/xml; charset=UTF-8">
<configuration>
<instruction property="titel" namespace="http://hippo.nl/cms/1.0"
xpath="string(/home/titel)"/>
</configuration>
</extractor>
</extractors>
This works with my adjustments.
Hth,
Nick Stolwijk
-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Ard Schrijvers
Sent: Tue 11/20/2007 11:59 AM
To: Hippo CMS development public mailinglist
Subject: RE: [HippoCMS-dev] Namespaces in documents with extractor
Hello Nick,
Can you try the following:
<configuration>
<xmlnamespace prefix="cms"
uri="http://www.test.nl/online/cms/hippo"/>
<instruction property="titel"
namespace="http://hippo.nl/cms/1.0"
xpath="string(/cms:home/cms:titel)"/>
</configuration>
in combination with org.apache.slide.extractor.SimpleXmlExtractor
instead of HippoSimpleXmlExtractor.
You should be able to define multiple <namespace> elements after
eachother, just like instructions.
Can you confirm wether this works. If so, we know a little more.
Currently, the HippoSimpleXmlExtractor is not build to work with
namespaces in content, but I could add this (or make him ignore
namespaces anyway, and extract regardless the namespace)
WDOT?? Should we add this?
Ard
> We are saving our documents with a namespace in it, like:
>
> <?xml version="1.0" encoding="utf-8"?>
> <home xmlns="http://www.test.nl/online/cms/hippo"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.t.nl/online/cms/hippo
> home.xsd" taal="nl" land="NL">
> <titel>foobar</titel>
> </home>
>
> Only our extractor stopped working. Is there a possibility to
> give the namespace to the extractor?
>
> Original extractor config:
> <?xml version="1.0"?>
> <extractors>
> <extractor
> classname="nl.hippo.slide.extractor.HippoSimpleXmlExtractor"
> uri="/files/default.preview/content"
> content-type="text/xml | application/xml |
> text/xml; charset=UTF-8">
> <configuration>
> <instruction property="titel"
> namespace="http://hippo.nl/cms/1.0" xpath="string(/home/titel)"/>
> </configuration>
> </extractor>
> </extractors>
>
> We've tried to change this to:
> <?xml version="1.0"?>
> <extractors xmlns:cms="http://www.test.nl/online/cms/hippo">
> <extractor
> classname="nl.hippo.slide.extractor.HippoSimpleXmlExtractor"
> uri="/files/default.preview/content"
> content-type="text/xml | application/xml |
> text/xml; charset=UTF-8">
> <configuration>
> <instruction property="titel"
> namespace="http://hippo.nl/cms/1.0"
> xpath="string(/cms:home/cms:titel)"/>
> </configuration>
> </extractor>
> </extractors>
>
> But then the repository complains about:
> WARN 2007-11-20 11:25:04 [fortress.slide.domain]
> Exception while retrieving content: Prefix must resolve to a
> namespace: cms
>
> (The message appeared only after we've changed
> components/excalibur-slide/server/src/java/nl/hippo/slide/extr
> actor/HippoSimpleXmlExtractor.java to show the error.)
>
> Has someone experience with using namespace in documents
> inside the repository?
>
> With regards,
>
> Nick Stolwijk
> ********************************************
> Hippocms-dev: Hippo CMS development public mailinglist
>
********************************************
Hippocms-dev: Hippo CMS development public mailinglist
Index:
components/excalibur-slide/server/src/java/nl/hippo/slide/extractor/HippoSimpleXmlExtractor.java
===================================================================
---
components/excalibur-slide/server/src/java/nl/hippo/slide/extractor/HippoSimpleXmlExtractor.java
(revision 8957)
+++
components/excalibur-slide/server/src/java/nl/hippo/slide/extractor/HippoSimpleXmlExtractor.java
(working copy)
@@ -40,7 +40,7 @@
Map properties = new HashMap();
try {
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
- dbf.setNamespaceAware(true);
+ dbf.setNamespaceAware(false);
dbf.setValidating(false);
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.parse(content);
@@ -55,13 +55,13 @@
}
} catch (IOException e) {
- throw new ExtractorException("Exception while retrieving content");
+ throw new ExtractorException("Exception while retrieving content:
" + e.getMessage());
} catch (SAXException e) {
- throw new ExtractorException("Exception while retrieving content");
+ throw new ExtractorException("Exception while retrieving content:
" + e.getMessage());
} catch (ParserConfigurationException e) {
- throw new ExtractorException("Exception while retrieving content");
+ throw new ExtractorException("Exception while retrieving content:
" + e.getMessage());
} catch (TransformerException e) {
- throw new ExtractorException("Exception while retrieving content");
+ throw new ExtractorException("Exception while retrieving content:
" + e.getMessage());
}
return properties;
}
********************************************
Hippocms-dev: Hippo CMS development public mailinglist