[opencms-dev] OpenCms 7.5.2: Howto use tool --Convert XML contents--

Kunicke, Holger holger.kunicke at av-studio.de
Tue Oct 30 12:50:27 CET 2012


Hi Kai,

my XSL file would looks like:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="xml" media-type="text/xml" 
cdata-section-elements="content" />
     <xsl:template match="/">
         <Overviews 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="opencms://system/modules/de.mwsg.spool.cms.modules.mastertemplates/schemas/newschema.xsd">
             <xsl:apply-templates/>
         </Overviews>
     </xsl:template>
     <xsl:template match="Freitext">
         <xsl:element name="Overview">
             <xsl:attribute name="language"><xsl:value-of 
select="@language" /></xsl:attribute>
             <Title><xsl:value-of select="Titel"/></Title>
             <!-- ... the rest of the elements -->
         </xsl:element>
     </xsl:template>
</xsl:stylesheet>


Be sure that the XSD File of the new type allow empty elements or the 
temporary absence of all elements ( minOccurs="0" ). This makes the job 
easier.

Regards
Holger

Am 30.10.2012 12:00, schrieb Schliemann, Kai:
>
> Hi list,
>
> I am trying to convert one xml content type to another using the 
> "Convert XML contents" tool in the administration view of OpenCms.
>
> I don't get it to work.
>
> Can anybody tell me what I am doing wrong or provide a working example 
> (I couldn't find one), please.
>
> Thank you very much in advance.
>
> Best regards
>
> Kai
>
> *This is the message I get during transformation:*
>
> #####################
>
> Resource path: /a/b/c/
> Inclusive sub folders: true
> Xslt file: /transform.xslt
> Only count files to transform: false
> New xsd main file: 
> opencms://system/modules/module.name/schemas/overview.xsd
> Start searching for files to transform...
> Number of files found to transform: 2
> Transform (published) file (encoding type): 
> /sites/default/a/b/c/d/content.html (UTF-8)
> Error while writing.
> Transform (published) file (encoding type): 
> /sites/default/a/b/c/content1.html (UTF-8)
> Error while writing.
> Publishing files...
> Result:
> Number of files found to transform: 2
> Number of files already transformed: 0
> Number of errors while transforming: 2
> Number of locked files (could not become transformed): 0
> Transforming files failed.
> Finished transforming xml contents.
> Statistics:duration: 00:00:00
>
> #####################
>
> *This is my setup:*
>
> *My xslt file for transformation:*
>
> #####################
>
> <?xml version="1.0" ?>
>
> <xsl:stylesheet version="1.0"
>
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:noNamespaceSchemaLocation="opencms://system/modules/module.name/schemas/newschema.xsd"
>
> >
>
>   <xsl:output method="xml" indent="yes"/>
>
>   <xsl:template match="/">
>
> <Title><![CDATA[]]></Title>
>
> <Headline><xsl:value-of select="/headline"/></Headline>
>
> <BoxesPath><![CDATA[]]></BoxesPath>
>
> <BoxRubrikUebersicht>
>
> <BoxPic><xsl:value-of select="/teaserImage"/></BoxPic>
>
> <BoxTitle><xsl:value-of select="/teaserText"/></BoxTitle>
>
> <BoxText name="BoxText0">
>
> <links><xsl:value-of select="/mainText/links"/></links>
>
> <content><xsl:value-of select="/mainText/content"/></content>
>
> </BoxText>
>
> </BoxRubrikUebersicht>
>
> <LeftNavigationenBoxes>
>
> <Boxpath><![CDATA[]]></Boxpath>
>
> <BoxTransmissionIndex><![CDATA[]]></BoxTransmissionIndex>
>
> </LeftNavigationenBoxes>
>
>   </xsl:template>
>
>   <xsl:template match="*"/>
>
> </xsl:stylesheet>
>
> #####################
>
> *New controlcode (contextmenu **à**advanced **à**edit controlcode)*
>
> #####################
>
> <Overviews xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:noNamespaceSchemaLocation="opencms://system/modules/de.mwsg.spool.cms.modules.mastertemplates/schemas/newschema.xsd">
>
>   <Overview language="de">
>
> <Title><![CDATA[mytitle]]></Title>
>
> <Headline><![CDATA[myheadline]]></Headline>
>
> <BoxesPath><![CDATA[/a/b/c/mybox.html]]></BoxesPath>
>
> <BoxRubrikUebersicht>
>
> <BoxPic><![CDATA[/_resources/images/Kategorie2.jpg]]></BoxPic>
>
> <BoxTitle><![CDATA[myboxtitle]]></BoxTitle>
>
>       <BoxText name="BoxText0">
>
>         <links/>
>
> <content><![CDATA[<p> kurzer Text</p>]]></content>
>
>       </BoxText>
>
> </BoxRubrikUebersicht>
>
> <LeftNavigationenBoxes>
>
> <Boxpath><![CDATA[/a/b/c/mybox2.html]]></Boxpath>
>
> <BoxTransmissionIndex>true</BoxTransmissionIndex>
>
> </LeftNavigationenBoxes>
>
>   </Overview>
>
> </Overviews>
>
> #####################
>
> *Old controlcode (contextmenu **à**advanced **à**edit controlcode)*
>
> #####################
>
> <Freitexts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> xsi:noNamespaceSchemaLocation="opencms://system/modules/module.name/schemas/oldschema.xsd">
>
>   <Freitext language="de">
>
> <headline><![CDATA[myheadline]]></headline>
>
>     <teaserImage/>
>
>     <teaserText name="teaserText0">
>
>       <links/>
>
> <content><![CDATA[Teaser-Text]]></content>
>
>     </teaserText>
>
>     <mainText name="mainText0">
>
>       <links/>
>
> <content><![CDATA[content text]]></content>
>
>     </mainText>
>
>   </Freitext>
>
> </Freitexts>
>
> #####################
>


-- 
_________________________________________
Holger Kunicke
Webentwickler

AV-Studio Kommunikationsmedien GmbH Halle
Stephanusstraße 2
06114 Halle (Saale)

Tel.: +49 (0) 345 20 999 -0
Fax:  +49 (0) 345 20 999 -20

Mail: holger.kunicke at av-studio.de
Web:  www.av-studio.de

HRB 11368
Ust-Id-Nr.: DE 191537712
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20121030/e03968e9/attachment.htm>


More information about the opencms-dev mailing list