[opencms-dev] Adding a new element into xml content programatically

Chuck Mysak chuck.mysak at gmail.com
Fri Dec 12 17:27:41 CET 2008


It worked.
Thank you, Sebastian. You're a life saver.

Chuck

On Fri, Dec 12, 2008 at 5:15 PM, Sebastian Himberger <
sebastian.himberger at gmx.de> wrote:

> Hi,
>
> it's the addValue method. I put together some example JSP calls on my blog:
>
>
>
> http://www.sebastian.himberger.de/blog/2008/12/12/manipulating-opencms-xmlcontent-programatically-some-examples
>
> I keep forgetting it too. This is the important part:
>
> // This is a new version (in this case it is a nested schema
> I_CmsXmlContentValue addedVersionValue =
> xmlContent.addValue(cmso,versionElement ,locale,0);
>
> // Add a new element to the created version (nested schema)
> I_CmsXmlContentValue addedFileValueRaw = xmlContent.addValue(
>  cmso,addedVersionValue.getPath() + "/" + fileElement,locale,0);
> CmsXmlVfsFileValue addedFileValue = (CmsXmlVfsFileValue )
> addedFileValueRaw;
> addedFileValue.setStringValue(cmso,resource);
>
> Best regards,
> Sebastian
>
> Chuck Mysak schrieb:
> > Hello,
> >
> > I've tried it, but the only method I found there that was related to
> > what I have to do was *addValue*, but this only works if the element
> > is already in the document. I need to find a way to add a new element
> > (from the editor it's the little green plus sign) to the document
> > that's a OpenCmsVfsFile. Is there another method there that I've
> > overlooked?
> >
> > Thank you,
> >
> > Chuck
> >
> > On Thu, Dec 11, 2008 at 9:34 PM, Sebastian Himberger
> > <sebastian.himberger at gmx.de <mailto:sebastian.himberger at gmx.de>> wrote:
> >
> >     Hi Chuck,
> >
> >     have you tried this? I don't really now if this is what you're
> >     looking for.
> >
> >
> http://files.opencms.org/javadoc/core/org/opencms/xml/content/CmsXmlContent.html#addValue(org.opencms.file.CmsObject,%20java.lang.String,%20java.util.Locale,%20int)
> >     <
> http://files.opencms.org/javadoc/core/org/opencms/xml/content/CmsXmlContent.html#addValue%28org.opencms.file.CmsObject,%20java.lang.String,%20java.util.Locale,%20int%29
> >
>  >
> >     best regards,
> >     Sebastian
> >
> >     Chuck Mysak schrieb:
> >     > Hello all,
> >     >
> >     > I have a problem regarding adding a new element into a structured
> >     > content file.
> >     > The element is of *OpenCmsVfsFile* type.
> >     >
> >     > I have tried the following:
> >     > - editing the element using CmsXmlContent doesn't do the trick, the
> >     > element doesn't exist (by default it has to be added in the editor)
> >     > - adding the element using CmsXmlPage didn't work, because when I
> >     > unmarshalled the page using the existing file, I was left with an
> >     > empty xml
> >     >
> >     > If someone has an idea, please help
> >     >
> >     > Thank you,
> >     >
> >     > Chuck
> >     >
> >
> ------------------------------------------------------------------------
> >     >
> >     >
> >     > _______________________________________________
> >     > This mail is sent to you from the opencms-dev mailing list
> >     > To change your list options, or to unsubscribe from the list,
> >     please visit
> >     > http://lists.opencms.org/mailman/listinfo/opencms-dev
> >
> >
> >     _______________________________________________
> >     This mail is sent to you from the opencms-dev mailing list
> >     To change your list options, or to unsubscribe from the list,
> >     please visit
> >     http://lists.opencms.org/mailman/listinfo/opencms-dev
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> > _______________________________________________
> > This mail is sent to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list, please
> visit
> > http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20081212/8258a97e/attachment.htm>


More information about the opencms-dev mailing list