Skip to content

Commit

Permalink
Update doc examples to latest version
Browse files Browse the repository at this point in the history
Closes #301.
  • Loading branch information
clenk committed Aug 30, 2016
1 parent 0f6f5d1 commit 8cd48dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions docs/overview/controlled_vocabularies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ values.
header = STIXHeader()
header.package_intents.append(PackageIntent.TERM_INDICATORS)
print header.to_xml()
print(header.to_xml())
Which outputs:

Expand Down Expand Up @@ -92,7 +92,7 @@ requirements.
non_default_term = VocabString("NON-DEFAULT VOCABULARY TERM")
header.package_intents.append(non_default_term)
print header.to_xml()
print(header.to_xml())
Which outputs:

Expand Down Expand Up @@ -248,6 +248,7 @@ XML Schema definition, but in Python!
# python-stix modules
from stix.core import STIXPackage
from stix.common.vocabs import VocabString, register_vocab
from mixbox.namespaces import register_namespace, Namespace
XML = \
"""
Expand All @@ -274,6 +275,7 @@ XML Schema definition, but in Python!
_XSI_TYPE = 'customVocabs:CustomVocab-1.0'
TERM_FOO = 'FOO'
TERM_BAR = 'BAR'
register_namespace(Namespace(CustomVocab._namespace, "customVocabNS"))
# Parse the input document
sio = StringIO(XML)
Expand All @@ -283,12 +285,12 @@ XML Schema definition, but in Python!
package_intent = package.stix_header.package_intents[0]
# Print information about the input Package_Intent
print type(package_intent), package_intent.xsi_type, package_intent
print('%s %s %s' % (type(package_intent), package_intent.xsi_type, package_intent))
# Add another Package Intent
bar = CustomVocab('BAR')
package.stix_header.add_package_intent(bar)
# This will include the 'BAR' CustomVocab entry
print package.to_xml()
print(package.to_xml())
10 changes: 6 additions & 4 deletions docs/overview/id_namespaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ a dictionary as a parameter.
.. code-block:: python
from stix.core import STIXPackage
from stix.utils import set_id_namespace
from mixbox.idgen import set_id_namespace
from mixbox.namespaces import Namespace
NAMESPACE = {"http://MY-NAMESPACE.com" : "myNS"}
NAMESPACE = Namespace("http://MY-NAMESPACE.com", "myNS")
set_id_namespace(NAMESPACE) # new ids will be prefixed by "myNS"
stix_package = STIXPackage() # id will be created automatically
Expand All @@ -25,11 +26,12 @@ Which outputs:
.. code-block:: xml
<stix:STIX_Package
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:myNS="http://MY-NAMESPACE.com"
xmlns:stixCommon="http://stix.mitre.org/common-1"
xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1"
xmlns:stix="http://stix.mitre.org/stix-1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
id="myNS:Package-b2039368-9476-4a5b-8c1d-0ef5d1b37e06" version="1.2"/>
Success! The ``xmlns:myNS="http://MY-NAMESPACE.com"`` matches our ``NAMESPACE``
Expand Down

0 comments on commit 8cd48dd

Please sign in to comment.