You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't tested this in all elements but I have provided a specific test case(TOUMarking:Terms_Of_Use) below:
input.xml:
<!-- This online template may be used as a starting point for creating STIX documents. Fill in the appropriate elements and add data as necessary. When finished, extra namespace declarations and schema locations may (but do not have to be) removed. All content (including the markings) are for sample purposes only and do not reflect actual threat intelligence or handling instructions. The copyright statement and license reference below (in addition to this entire comment) may be removed once this file is altered. When distributed in its current form as the STIX online template, however, it should be retained to indicate it is part of the STIX open source project. ****************************************************************************************************************************** Copyright (c) 2014, The MITRE Corporation. All rights reserved. The contents of this file are subject to the terms of the STIX License located at http://stix.mitre.org/about/termsofuse.html. ******************************************************************************************************************************-->
<stix:STIX_Packagexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:marking="http://data-marking.mitre.org/Marking-1"xmlns:stixCommon="http://stix.mitre.org/common-1"xmlns:stix="http://stix.mitre.org/stix-1"xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1"xmlns:TOUMarking="http://data-marking.mitre.org/extensions/MarkingStructure#Terms_Of_Use-1"xsi:schemaLocation=" http://data-marking.mitre.org/Marking-1 http://stix.mitre.org/XMLSchema/data_marking/1.1.1/data_marking.xsd http://stix.mitre.org/common-1 http://stix.mitre.org/XMLSchema/common/1.1.1/stix_common.xsd http://stix.mitre.org/stix-1 http://stix.mitre.org/XMLSchema/core/1.1.1/stix_core.xsd http://stix.mitre.org/default_vocabularies-1 http://stix.mitre.org/XMLSchema/default_vocabularies/1.1.1/stix_default_vocabularies.xsd http://data-marking.mitre.org/extensions/MarkingStructure#Terms_Of_Use-1 http://stix.mitre.org/XMLSchema/extensions/marking/terms_of_use/1.0.1/terms_of_use_marking.xsd "id="INSERT_PACKAGE_ID_HERE"version="1.1.1">
<stix:STIX_Header>
<stix:Title>TITLE</stix:Title>
<stix:Package_Intentxsi:type="stixVocabs:PackageIntentVocab-1.0">Incident</stix:Package_Intent>
<stix:Description>DESCRIPTION</stix:Description>
<!-- All handling instructions are for sample purposes only. Feel free to remove, change, and add as you see fit. -->
<stix:Handling>
<marking:Marking>
<marking:Controlled_Structure>//node()</marking:Controlled_Structure>
<marking:Marking_Structurexsi:type="TOUMarking:TermsOfUseMarkingStructureType">
<TOUMarking:Terms_Of_Use></TOUMarking:Terms_Of_Use>
</marking:Marking_Structure>
</marking:Marking>
</stix:Handling>
</stix:STIX_Header>
</stix:STIX_Package>
python script:
#!/usr/bin/env python# Copyright (c) 2014, The MITRE Corporation. All rights reserved.# See LICENSE.txt for complete terms.'''File: ex_01.pyDescription: Round-trip example. This script takes a STIX instance document from XML toa binding object, then to a api object and then to a dictionary. That dictionary is thenconverted back into an api object, which is then used to generate an XML document.'''importiofrompprintimportpprintfromstix.coreimportSTIXPackagedefmain():
fn='input.xml'stix_package=STIXPackage.from_xml(fn)
stix_dict=stix_package.to_dict() # parse to dictionary#pprint(stix_dict)stix_package_two=STIXPackage.from_dict(stix_dict) # create python-stix object from dictionaryxml=stix_package_two.to_xml() # generate xml from python-stix objectprint(xml)
if__name__=='__main__':
main()
The text was updated successfully, but these errors were encountered:
marlontaylor
changed the title
Going round-trip with blank element results in no element (possible invalid XML)
Going round-trip with blank element results in no element in XML (possible invalid XML)
Sep 16, 2014
I haven't tested this in all elements but I have provided a specific test case(TOUMarking:Terms_Of_Use) below:
input.xml:
python script:
resulting xml:
The text was updated successfully, but these errors were encountered: