还是关于名称空间的问题,我还是不明白,请大家帮助!

Borlan 2002-09-12 04:07:05
Form1.xsd代码如下,它包含了Form2Message.xsd

<schema targetNmaesapce=http://www.mypapers.com/FormMessage
xmlns:FormMessage=http://www.mypapers.com/FormMessage
xmlns=http://www.w3.org/2001/XMLSchema>
<include schemaLocation=http://www.mypapers.com/Form2Message.xsd/>
<element name=”content”>
<group>
<option>
<element ref=”FormMessage:body”/>
<element ref=”FormMessage:HTMLbody”/>
</option>
</group>
</element>
<element name=”body”>
<attribute name=”bodyText” type=”FormMessage:TextBody”/>
</element>
</schema>

Form2Message.xsd代码如下:
<xsd:schema targetNamespace:xsd=http://www.mypapers.com/FormMessage
xmlns=http://www.w3.org/2001/XMLSchema>
<xsd:simpleType name=”TextBody” base=”string” minLength=”0” maxLength=”20”/>
<xsd:element name=”HTMLbody”>
<xsd:attribute name=”bodyText” type=”string”/>
</xsd:element>
</xsd:schema>

问题是:
譬如在上面这段代码中,element元素的名称空间应该是默认的xmlns=http://www.w3.org/2001/XMLSchema吧,那么它的属性name的名称空间是不是也是这个呢? 那么属性值“body”的名称空间是什么呢?属性的名称空间与属性值的名称空间不是一回事,对吧??

希望各位帮忙解释一下,我这里还是比较糊涂:(((
谢谢!
...全文
33 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Borlan 2002-09-13
  • 打赏
  • 举报
回复
谢谢saucer!
也就是说在我的Form1.xsd中属性值body前应该加上FormMessage: 对吧?
你说Form2Message.xsd定义的不对,能否给出我正确的定义形式呢?

这两段代码是《Developing XML Solutions》这本书中Chapter7中Namespace and Schema这一小节中的一段代码,我由于需要写论文,就照着改了一下,源代码也是类似的,一个月前你回答的我的那个问题也是基于这个的,那个问题你回答的是这样的
targetNamespace="http://www.northwindtraders.com/Message"
<xsd:simpleType name="TextBody"...>

"TextBody" is in the namespace "http://www.northwindtraders.com/Message"

那么,属性值的名称空间应该跟谁呢?
书中的代码怎么回事??搞的我好乱
saucer 2002-09-12
  • 打赏
  • 举报
回复
in Form1.xsd, the default namespace is "http://www.w3.org/2001/XMLSchema", the namespace for "body" is this default namespace, not "http://www.mypapers.com/FormMessage"

by the way, the xsd file is invalid, you need to enclose attribute values in quotes.

but you did not define the namespace for xsd in Form2Message.xsd
Borlan 2002-09-12
  • 打赏
  • 举报
回复
可这不是DTD啊!!!!!!!!
是schema啊


大家帮帮忙,please....
ciby 2002-09-12
  • 打赏
  • 举报
回复
我觉得属性里的名称空间应该跟着DTD走,在DTD里如果其是默认的话,那这里就是默认的,在DTD里有在前面家如xsd:的前缀,这里也要加。

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧