以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  [求助]哪位高手能帮我看看这个基于GML的XML Schema有什么问题?很急啊!  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=39600)


--  作者:yaowei666
--  发布时间:11/1/2006 2:47:00 PM

--  [求助]哪位高手能帮我看看这个基于GML的XML Schema有什么问题?很急啊!
<?xml version="1.0" encoding="GB2312" ?>
<!-- edited with XML Explorer v2.0 by Mergesoft (www.mergesoft.com) -->
<xs:schema targetNamespace="http://www.w3.org/2001/XMLSchema"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns="http://www.w3.org/2001/XMLSchema"  
               xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:gml="http://www.opengis.net/gml"
 elementFormDefault="qualified">
 
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="E:\gml资料整理\gml所有标准\GML-3.1.1\base\feature.xsd" />
<xs:element name="CityModel" type="CityModelType"
                                                    substitutionGroup="gml:_FeatureCollection" />
<xs:complexType name="CityModelType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:sequence>
<xs:element name="dateCreated" type="string" />
<xs:element ref="cityMember" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="cityMember" type="CityMemberType"  
                                                          substitutionGroup="gml:featureMember" />
<xs:complexType name="CityMemberType">
<xs:complexContent>
<xs:restriction base="gml:FeaturePropertyType">
<xs:sequence minOccurs="0">
<xs:element ref="CityFeature" />
</xs:sequence>
<xs:attributeGroup ref="gml:AssociationAttributeGroup" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:element name="CityFeature" type="gml:AbstractFeatureType" abstract="true"  
                                                             substitutionGroup="gml:_Feature" />
<xs:element name="River" type="RiverType" substitutionGroup="CityFeature" />
<xs:complexType name="RiverType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element ref="gml:centerLineOf" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="Road" type="RoadType" substitutionGroup="CityFeature" />
<xs:complexType name="RoadType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="linearGeometry" type="gml:LineStringPropertyType" />
<xs:element name="classification" type="string" />
<xs:element name="number" type="string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- <xs:element name="Mountain" type="MountainType" substitutionGroup="gml:_Feature" />-->
<!-- <xs:complexType name="MountainType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="elevation" type="integer" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>-->
</xs:schema>

在XML Explorer环境下,点击“Compact View”,总是提示“This schema does not have root element!”。哪位高手能帮帮忙啊!


--  作者:yaowei666
--  发布时间:11/3/2006 10:43:00 AM

--  
找不到根结点的问题我已经解决了。将<xs:element name="CityModel" type="CityModelType"  substitutionGroup="gml:_FeatureCollection" />
改为<xs:element name="CityModel" type="CityModelType" />即可。
可是新的问题又来了。以下是我编写的city.xml和city.xsl文件。

city.xml文件:
?xml version="1.0" encoding="GB2312"?>
<CityModel xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation="E:\gml资料整理\gml实例总结\gml实例4\citymodelcopy.xsd">
<dateCreated>2006-11</dateCreated>
<cityMember>
<gml:boundedBy srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:Envelope>
<gml:coord><gml:X>0.0</gml:X><gml:Y>0.0</gml:Y></gml:coord>
<gml:coord><gml:X>100.0</gml:X><gml:Y>100.0</gml:Y></gml:coord>
</gml:Envelope>
</gml:boundedBy>
<Road>
<gml:name>南京东路</gml:name>
<gml:linearGeometry>
<gml:LineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord><gml:X>0</gml:X><gml:Y>5.0</gml:Y></gml:coord>
<gml:coord><gml:X>20.6</gml:X><gml:Y>10.7</gml:Y></gml:coord>
<gml:coord><gml:X>80.5</gml:X><gml:Y>60.9</gml:Y></gml:coord>
</gml:LineString>
</gml:linearGeometry>
<classification>主要道路</classification>
<number>8</number>
</Road>
</cityMember>
</CityModel>

city.xsl文件:
<?xml version="1.0" encoding="GB2312" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gml="http://www.opengis.net/gml">
  <xsl:output method="xml" indent="yes" media-type="image/svg+xml" />
<xsl:template match="/">
<svg>
<g style="stroke:#000000">
<text x="200" y="200">
  <xsl:value-of select="CityModel/dateCreated" />
  </text>
<xsl:variable name="x1">
  <xsl:value-of select="CityModel/cityMember/gml:boundedBy/gml:Envelope/gml:coord/gml:X" />
  </xsl:variable>
<xsl:variable name="y1">
  <xsl:value-of select="CityModel/cityMember/gml:boundedBy/gml:Envelope/gml:coord/gml:Y" />
  </xsl:variable>
  <circle cx="{$x1}" cy="{$y1}" r="25" fill="dodgerblue" />
  </g>
  </svg>
  </xsl:template>
  </xsl:stylesheet>

生成的SVG文件是:
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns:gml="http://www.opengis.net/gml">
<g style="stroke:#000000">
<text y="200" x="200"/>
<circle fill="dodgerblue" r="25" cy="" cx=""/>
</g>
</svg>

因为cx和cy没有值,所以图象显示不出来。那位高手能告诉我要怎样做才能显示图象啊!!!
我现在都要晕了!


--  作者:ynlws
--  发布时间:12/27/2007 3:11:00 PM

--  
在xsl文件里做一个判断行不行呢,如果x为零就显示0而不是空,呵呵
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
6,201.172ms