[opencms-dev] XML Content Demo

opencms at biberbeatz.de opencms at biberbeatz.de
Tue Nov 23 14:31:23 CET 2004


Hi,

I am new to OpenCMS and I tried to implement an xmlcontent based
article. I followed the instructions as described in an earlier post.
OpenCMS Version: OpenCms 6.0 alpha 2

But when I come to point 2 saving my document I get the following
exception.
I doublechecked my schema and XML file and it looks that they should
be ok because I tried it with a erroeous file and there I was promped
to correct my tagnames.

Something is wrong with the editor as far as understand the
exception:
Unable to unmarshal XML content definition schema

Requested resource: /system/workplace/editors/simple/editor.jsp
OpenCms version: 6.0 alpha 2 Caladan
OpenCms context: /opencms/opencms

<----stacktrace snippet------>
java.lang.RuntimeException: Unable to unmarshal XML content
definition schema
	at
org.opencms.xml.content.CmsXmlContent.getContentDefinition(CmsXmlCont
ent.java:173)
	at
org.opencms.xml.content.CmsXmlContent.<init>(CmsXmlContent.java:111)
	at
org.opencms.xml.content.CmsXmlContentFactory.unmarshal(CmsXmlContentF
actory.java:277)
	at
org.opencms.xml.content.CmsXmlContentFactory.unmarshal(CmsXmlContentF
actory.java:189)
	at
org.opencms.file.types.CmsResourceTypeXmlContent.writeFile(CmsResourc
eTypeXmlContent.java:209)
	at org.opencms.file.CmsObject.writeFile(CmsObject.java:667)
	at
org.opencms.workplace.editors.CmsSimpleEditor.actionSave(CmsSimpleEdi
tor.java:195)
	at org.apache.jsp.editor_jsp._jspService(editor_jsp.java:84)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:210)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2
95)
	at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
atcher.java:684)
	at
org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationD
ispatcher.java:575)
	at
org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDis
patcher.java:498)
	at
org.opencms.flex.CmsFlexRequestDispatcher.includeExternal(CmsFlexRequ
estDispatcher.java:357)
	at
org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexRequestDispa
tcher.java:163)
	at
org.opencms.loader.CmsJspLoader.service(CmsJspLoader.java:411)
	at
org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexRequestDispa
tcher.java:293)
	at
org.opencms.jsp.CmsJspTagInclude.includeTagAction(CmsJspTagInclude.ja
va:210)
	at
org.opencms.jsp.CmsJspActionElement.include(CmsJspActionElement.java:
245)
	at
org.opencms.jsp.CmsJspActionElement.include(CmsJspActionElement.java:
190)
	at
org.apache.jsp.editor_main_jsp._jspService(editor_main_jsp.java:49)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
<----stacktrace snippet------>


>> Version 6 is fantastic! I'm still getting to know the system. 
>>  I was going to use version 5 for a website being put up in 
>> about a month, but I need the functionality of the XML 
>> Content.  I was going to make my own Content Definition and 
>> module, but the XML content method seems more powerful, and 
>> easier to duplicate.  I know there is no formal documentation 
>> for version 6, but if someone could just give me a layout of 
>> the basic steps to create my own xml content I would really 
>> appreciate it.  

>Here's the short overview about how to create XML content
definitions. Feel
>free to ask additional questions if something seems inclomplete.

>1. Start with the XML schema
>You first need to define the XML content structure. To do this,
create an
>XML schema (currently this is just a "plain" file). The XML schema
mut
>follow the layout of the demo files. Check out
"/xmlcontent/article.xsd" and
>all files in
"/system/modules/org.opencms.frontend.templateone/schemas/"
>which give you a couple of examples. Please note that the layout is
>mandatory, in case you make any mistake it wont word. A fine point
is that
>there's always an "inner" and "outer" node name, e.g. "article" and
>"articles". The "outer" name _must_ be the inner name with an "s"
appended.
>For the current choice of available data types check the demos and
the file
>"opencms-vfs.xml". For the beginning, I recommend you start with a
very
>small schema, maybe based on "article.xsd" where you _remove_ most
of the
>nodes, and rename the schema to "myarticle". Just leave the title
data
>field.
>
>The first schema might look like this:
><?xml version="1.0" encoding="UTF-8"?>
>
><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>elementFormDefault="qualified">
>	
>	<xsd:include
schemaLocation="opencms://opencms->xmlcontent.xsd"/>
>
>	<xsd:element name="myarticles" type="OpenCmsMyArticles"/>
>	
>	<xsd:complexType name="OpenCmsMyArticles">
>		<xsd:sequence>
>			<xsd:element name="myarticle"
>type="OpenCmsMyArticle" minOccurs="0" maxOccurs="unbounded"/>
>		</xsd:sequence>
>	</xsd:complexType>
>
>	<xsd:complexType name="OpenCmsMyArticle">
>		<xsd:sequence>
>			<xsd:element name="title"
>type="OpenCmsString" />
>		</xsd:sequence>
>		<xsd:attribute name="language" type="OpenCmsLocale"
>use="required"/>
>	</xsd:complexType>
>
>	<xsd:annotation>
>		<xsd:appinfo>
>			<mapping element="Title"
>mapto="property:Title" />
>		</xsd:appinfo>
>	</xsd:annotation>  
></xsd:schema>
>
>
>
>2. Create a content with the new schema. 
>Since the schema is not yet available for creating "new" files, you
must do
>that manually. Create a new file of type "Generic XML content". This
will be
>just an empty file. Now open that file with "Edit controlcode". Then
supply
>a valid XML for the schema, like this:
>
><?xml version="1.0" encoding="UTF-8"?>
>
><myarticles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xsi:noNamespaceSchemaLocation="opencms://sites/default/xmlcontent/my
article.
>xsd">
>  <myarticle language="en">
>    <title><![CDATA[Sample article 1]]></title>
>  </myarticle>
></mayrticles>
>
>The fine point here's the pointer to the XML schema in the VFS using
>xsi:noNamespaceSchemaLocation="opencms://sites/default/xmlcontent/my
article.
>xsd". You mut point to the location of your schema here.
>
>Note that the "Edit controlcode" editor will not allow you to save
the
>content if either the schema contains errors, or the XML is not
formed
>according to the schema. So if you can't save, check that both the
schema
>and the XML is vaild. Once you are able to save, you are certain
that it
>worked. 
>
[..]

Thanks for your help.
Best regards,

Jan-Ph. Schiller



More information about the opencms-dev mailing list