简体   繁体   English

OpenCms:如何从多个架构文件访问xml元素内容

[英]OpenCms : How to access xml element content from multiple schema files

I have a doubt regarding xml structured content in OpenCms. 我对OpenCms中的xml结构化内容有疑问。 I have two XML schemas, one for editing the top menus (menus are same across all the pages) and another schema for editing the page content. 我有两种XML模式,一种用于编辑顶部菜单(所有页面的菜单都相同),另一种用于编辑页面内容。 In the template jsp file i need to access xml element contents from both the schema files. 在模板jsp文件中,我需要从两个模式文件中访问xml元素的内容。 How to go for that? 怎么去的? do i have to specify something in ? 我必须指定一些内容吗?

You can embed one xsd into another. 您可以将一个xsd嵌入另一个。 First you define your menu via menu.xsd, then you include it like this in your ie page.xsd: 首先,您通过menu.xsd定义菜单,然后将其包含在ie page.xsd中:

<xsd:include schemaLocation="opencms://system/modules/com.yourmodule.www/schemas/menu.xsd"/>
...
<xsd:element name="Menu" type="OpenCmsMenu" minOccurs="1" maxOccurs="1" />

where 'OpenCmsMenu' needs to be the type name as you defined it in your menu.xsd. “ OpenCmsMenu”必须是您在menu.xsd中定义的类型名称。

An alternative solution might be to generate the menus from the folder structure. 一种替代解决方案可能是从文件夹结构生成菜单。 That is the usual method to deal with menus in OpenCms. 这是在OpenCms中处理菜单的常用方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM