[opencms-dev] Problem with CmsXmlPageFactory.unmarshal creating only empty pages
Eska
sven.kiesow at interone.de
Thu Feb 11 12:10:34 CET 2010
Hi List,
I am trying to program me a little jsp tool that does the same as
CmsMergePages.mergePages(),
but somehow the call to CmsXmlPageFactory.unmarshal() only creates empty
CmsXmlPage
objects for me.
String resPathDe = "/sites/abc/de/test.html";
String resPathEn = "/sites/abc/en/testa.html";
CmsFile resFileDe = cmsObj.readFile(resDe);
CmsFile resFileEn = cmsObj.readFile(resEn);
Locale de = new Locale("de");
Locale en = new Locale("en");
CmsXmlPage xmlPageDe = CmsXmlPageFactory.unmarshal(cmsObj, resFileDe);
CmsXmlPage xmlPageEn = CmsXmlPageFactory.unmarshal(cmsObj, resFileEn);
Locale locDe = new Locale("de");
Locale locEn = new Locale("en");
List textElements2 = xmlPageEn.getNames(locEn );
Iterator j = textElements2.iterator();
while (j.hasNext()) {
String textElementName = (String)j.next();
String textElement = xmlPageEn.getValue(textElementName,
locEn).getStringValue(cmsObj);
if (!xmlPageDe.hasValue(textElementName, locEn)) {
xmlPageDe.addValue(textElementName, locEn);
}
xmlPageDe.setStringValue(cmsObj, textElementName, locEn, textElement);
}
...
When now trying to combine both page contents like in the
CmsMergePages.mergePages() method,
an empy content is created only containing only the following:
<?xml version="1.0" encoding="UTF-8"?>
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.opencms.org/dtd/6.0/xmlpage.xsd"></pages>
I gathered the following data:
resFileDe.getContents().length: 889
resFileEn.getContents().length: 1024
xmlPageDe.getNames(de).size(): 0
xmlPageEn.getNames(en).size(): 0
xmlPageDe.getValues(de).size(): 0
xmlPageEn.getValues(en).size(): 0
xmlPageDe.getLocales().size(): 0
xmlPageEn.getLocales().size(): 0
textElements2.size()=0
My two files have normal content like this:
<?xml version="1.0" encoding="UTF-8"?>
<ArticlePages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="opencms://system/modules/my.test.module/schemas/articlepage.xsd">
<ArticlePage language="de">
<Status><![CDATA[7]]></Status>
<TopProject>false</TopProject>
<Headline><![CDATA[This is a Headline!]]></Headline>
<Text name="Text0">
...
</ArticlePage>
</ArticlePages>
Is it the wrong way to try to merge to contents?
Thanks,
Eska.
--
View this message in context: http://old.nabble.com/Problem-with-CmsXmlPageFactory.unmarshal-creating-only-empty-pages-tp27544324p27544324.html
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
More information about the opencms-dev
mailing list