-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VocabString cannot parse third-party CVs #145
Comments
My testing, proprietary Controlled Vocabulary schema <?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:testVocabs="http://testvocabs.com/vocabs-1" xmlns:stixCommon="http://stix.mitre.org/common-1" targetNamespace="http://testvocabs.com/vocabs-1" elementFormDefault="qualified" version="1.1.1" xml:lang="English">
<xs:import namespace="http://stix.mitre.org/common-1" schemaLocation="stix_common.xsd"/>
<xs:complexType name="TestVocab-1.0">
<xs:simpleContent>
<xs:restriction base="stixCommon:ControlledVocabularyStringType">
<xs:simpleType>
<xs:union memberTypes="testVocabs:TestEnum-1.0"/>
</xs:simpleType>
<xs:attribute name="vocab_name" type="xs:string" use="optional" fixed="Test Vocab"/>
<xs:attribute name="vocab_reference" type="xs:anyURI" use="optional" fixed="http://example.com/TestVocab"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="TestEnum-1.0">
<xs:restriction base="xs:string">
<xs:enumeration value="TEST">
<xs:annotation>
<xs:documentation>Testing</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:schema> My test instance document ("TESTVOCAB.xml"). I override the default Package_Intent CV to use my <stix:STIX_Package
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:stix="http://stix.mitre.org/stix-1"
xmlns:testVocabs="http://testvocabs.com/vocabs-1"
xmlns:example="http://example.com/"
xsi:schemaLocation="
http://stix.mitre.org/stix-1 ../stix_core.xsd
http://testvocabs.com/vocabs-1 ../my_vocabs.xsd"
id="example:STIXPackage-33fe3b22-0201-47cf-85d0-97c02164528d"
timestamp="2014-05-08T09:00:00.000000Z"
version="1.1.1">
<stix:STIX_Header>
<stix:Package_Intent xsi:type="testVocabs:TestVocab-1.0">TEST</stix:Package_Intent>
</stix:STIX_Header>
</stix:STIX_Package> The python code to parse this requires developers to create their own from stix.core import STIXPackage
from stix.common.vocabs import VocabString, add_vocab
class TestVocab(VocabString):
_namespace = 'http://testvocabs.com/vocabs-1'
_XSI_TYPE = 'testVocabs:TestVocab-1.0'
add_vocab(TestVocab)
s = STIXPackage.from_xml("TESTVOCAB.xml")
print s.stix_header.package_intents[0].xsi_type # prints testVocabs:TestVocab-1.0 This parses the document just fine, and prints the I am going to address the serialization bug and change the behavior of |
The following commits have addressed a couple of issues:
To be done:
|
Still need to figure out:
|
Closing this issue now. |
When attempting to parse an instance document that utilizes a third party CV, an exception is raised. Here is some test output:
This issue was raised during the STIX Community call on 2014/06/12.
Related to #97
The text was updated successfully, but these errors were encountered: