3
我试图使用lxml.etree
来重现CDA QuickStart Guide found here中的CDA示例。lxml xsi:schemaLocation名称空间URI验证问题
特别是,我遇到了命名空间试图重新创建这个元素的问题。
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:mif="urn:hl7-org:v3/mif"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd">
我正在使用的代码如下
root = etree.Element('ClinicalDocument',
nsmap={None: 'urn:hl7-org:v3',
'mif': 'urn:hl7-org:v3/mif',
'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'{http://www.w3.org/2001/XMLSchema-instance}schemaLocation': 'urn:hl7-org:v3 CDA.xsd'})
的问题是,在nsmap
的schemaLocation
条目。 lxml
似乎试图验证的值,并给出了错误
ValueError: Invalid namespace URI u'urn:hl7-org:v3 CDA.xsd'
我是否指定schemaLocation
值不正确?有没有办法强制lxml
接受任何字符串值?或者,这个例子中的值是否仅仅是一个占位符,我应该用其他东西代替?
感谢您挖掘它,我放弃了寻找答案。 – user3419537