开发者

XSD question - Calling an xsd from another xsd

I know I have seen this somewhere before, but I cannot find it again. I need an example of calling an xsd file from within another xsd. This is quite useful where a number for xml files are being generated, but where there is large common areas between these xml files being validated. In that scenario, it is useful to have an xsd that validates the parts common to all xml files, then have separat开发者_如何学Ce smaller xsd validation files for the parts of the xml that are specific to each xml file. Thanks


I'd probably call it referencing another XSD file (calling implies that the XSD is run or executed in some way, which isn't the case).

In any case you are probably looking for either the import or the include elements, for example:

<?xml version="1.0"?>
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.w3.org/2001/05/XMLInfoset" xmlns="http://www.w3.org/2001/XMLSchema">
  <xs:import namespace="http://www.example.com/IPO" />
  <xs:include schemaLocation="example.xsd" />
</xs:schema>

What is the difference between import and include? Use import to reference declarations in a different namespace and include to reference declarations in the same namespace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜