<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi there,<br>
<br>
I have the following problem, I have defined a xsd file for
structured Xml Content, and I want to use a jsp to fill this XML
File. Filling in strings already works, but I wanted to add a Date
Field which I can't seem to fill in. Here is how my stuff works
already... I copy a "template" html xml structured content to a new
resource and open up that resource and fill in the values of the xml
elements. The only thing I don't know how to add is the DateField.<br>
<br>
Thanks for helping me out.<br>
<br>
-- newstemplate.xsd --<br>
<br>
<tt><xsd:schema xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
elementFormDefault="qualified"><br>
<xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"
/><br>
<xsd:element name="XmlContentDocSimpleTypes"
type="OpenCmsXmlContentDocSimpleTypes" /><br>
<xsd:complexType name="OpenCmsXmlContentDocSimpleTypes"><br>
<xsd:sequence><br>
<xsd:element name="XmlContentDocSimpleType"
type="OpenCmsXmlContentDocSimpleType" minOccurs="0"
maxOccurs="unbounded" /><br>
</xsd:sequence><br>
</xsd:complexType><br>
<xsd:complexType name="OpenCmsXmlContentDocSimpleType"><br>
<xsd:sequence><br>
<xsd:element name="Title" type="OpenCmsString"
minOccurs="1" maxOccurs="1" /><br>
<xsd:element name="Teaser" type="OpenCmsString"
minOccurs="1" maxOccurs="1" /><br>
<xsd:element name="Text" type="OpenCmsHtml"
minOccurs="1" maxOccurs="1" /><br>
<xsd:element name="ReleaseDate" type="OpenCmsDateTime"
minOccurs="1" maxOccurs="1" /><br>
<xsd:element name="Author" type="OpenCmsString"
minOccurs="1" maxOccurs="1" /><br>
</xsd:sequence><br>
<xsd:attribute name="language" type="OpenCmsLocale"
use="required" /><br>
</xsd:complexType><br>
<xsd:annotation><br>
<xsd:appinfo><br>
<resourcebundle
name="com.alkacon.documentation.xmlcontentdemo.workplace"/><br>
<mappings><br>
<mapping element="Title" mapto="property:Title"
/><br>
<mapping element="ReleaseDate"
mapto="attribute:datereleased" /><br>
</mappings><br>
<defaults><br>
<default element="Title" value="" /><br>
<default element="Teaser" value="" /><br>
<default element="ReleaseDate"
value="${currenttime}"/> <br>
<default element="Author"
value="${currentuser.fullname}"/> <br>
</defaults><br>
<layouts><br>
<layout element="Text" widget="HtmlWidget"
configuration="source,link,anchor,formatselect,image,table,imagegallery,downloadgallery,linkgallery,htmlgallery,tablegallery,height:400px"
/><br>
</layouts><br>
</xsd:appinfo><br>
</xsd:annotation> <br>
</xsd:schema></tt><br>
<br>
<br>
-- newstemplate.html --<br>
<tt><?xml version="1.0" encoding="UTF-8"?><br>
<br>
<XmlContentDocSimpleTypes
xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
xsi:noNamespaceSchemaLocation="opencms://sites/test/newstemplate.xsd"><br>
<XmlContentDocSimpleType language="en"><br>
<Title/><br>
<Teaser/><br>
<Text name="Text0"><br>
<links/><br>
<content/><br>
</Text><br>
<ReleaseDate /><br>
<Author/><br>
</XmlContentDocSimpleType><br>
</XmlContentDocSimpleTypes></tt><br>
<br>
<br>
-- my.jsp --<br>
<tt>...all imports and stuff...<br>
output is a string<br>
pubdate is a long<br>
............................<br>
<br>
<br>
CmsObject cms = OpenCms.initCmsObject("Guest");<br>
cms.loginUser("foo", "bar");<br>
CmsProject project = cms.readProject("Offline");<br>
cms.getRequestContext().setCurrentProject(project);<br>
cms.getRequestContext().setSiteRoot(siteroot);<br>
<br>
String filename = "/news001.html";<br>
String filenameResname =
cms.getRequestContext().getFileTranslator().translateResource(filename);<br>
int filenameResTypeId =
OpenCms.getResourceManager().getDefaultTypeForName(filename).getTypeId();<br>
<br>
# Make a copy of the template html<br>
cms.copyResource("/newstemplate.html", filename,
CmsResource.COPY_AS_NEW);<br>
<br>
CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(cms,
cms.readFile(filename));<br>
I_CmsXmlContentValue xmlContentValue = null;<br>
<br>
xmlContentValue = xmlContent.getValue("Title", new
Locale("en"));<br>
xmlContentValue.setStringValue(cms, title);<br>
xmlContentValue = xmlContent.getValue("Teaser", new
Locale("en"));<br>
xmlContentValue.setStringValue(cms, output);<br>
xmlContentValue = xmlContent.getValue("Text", new
Locale("en"));<br>
xmlContentValue.setStringValue(cms, output);<br>
xmlContentValue = xmlContent.getValue("Author", new
Locale("en"));<br>
xmlContentValue.setStringValue(cms, author);<br>
xmlContentValue = xmlContent.getValue("ReleaseDate", new
Locale("en"));<br>
xmlContentValue.setStringValue(cms,
String.valueOf(pubdateDate.getTime()));<br>
<br>
<br>
String xmlContentNews =
cms.getRequestContext().getFileTranslator().translateResource(filename);<br>
cms.lockResource(xmlContentNews);<br>
CmsFile xmlFile = xmlContent.getFile();<br>
xmlFile.setContents(xmlContent.marshal());<br>
cms.writeFile(xmlFile);<br>
<br>
<br>
<br>
</tt><br>
<div class="moz-signature">-- <br>
<p style="font: 12px verdana;">
Mat frendlechen Gréiss </p>
<table style="font: 9px verdana;" nowrap="">
<tbody>
<tr>
<td colspan="3" style="padding: 0pt;">
<hr style="height: 1px; background-color: rgb(0, 0, 0);
border: 0pt none;"></td>
</tr>
<tr>
<td style="padding: 12px;">
<a href="http://www.sita.lu"><img
src="cid:part1.02030700.00040002@sitasoftware.lu"
border="0"></a>
</td>
<td style="padding: 12px; width: 250px;" nowrap="nowrap">
<span style="font: 10px verdana;">Frank Lazzarini</span><br>
Programmeur
</td>
<td style="padding: 12px;" nowrap="nowrap">
Sita Software S.A.<br>
220, avenue de la Liberté<br>
L-4602 Niederkorn<br>
Grand Duché de Luxembourg<br>
Tel: (+352) 58 00 93-32<br>
Fax: (+352) 58 00 94
</td>
</tr>
<tr>
<td colspan="3" style="padding: 0pt;">
<hr style="height: 1px; background-color: rgb(0, 0, 0);
border: 0pt none;"></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>