Skip to content

Commit

Permalink
fixes #555
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Apr 9, 2017
1 parent 84c8576 commit 07eb8db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 58 deletions.
24 changes: 12 additions & 12 deletions nxdlTypes.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -418,18 +418,18 @@
<xs:annotation>
<xs:documentation>any valid NeXus type</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="NX_CHAR"><xs:annotation><xs:documentation>any string representation</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="NX_FLOAT"><xs:annotation><xs:documentation>any representation of a floating point number</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="NX_INT"><xs:annotation><xs:documentation>any representation of an integer number</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="NX_UINT"><xs:annotation><xs:documentation>any representation of an unsigned integer number (includes zero)</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="NX_POSINT"><xs:annotation><xs:documentation>any representation of a positive integer number (greater than zero)</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="NX_NUMBER"><xs:annotation><xs:documentation>any valid NeXus number representation</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="NX_DATE_TIME"><xs:annotation><xs:documentation>alias of ISO8601</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="ISO8601"><xs:annotation><xs:documentation>ISO 8601 date and time representation (http://www.w3.org/TR/NOTE-datetime)</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="NX_BOOLEAN"><xs:annotation><xs:documentation>true/false value ( true | 1 | false | 0 )</xs:documentation></xs:annotation></xs:enumeration>
<xs:enumeration value="NX_BINARY"><xs:annotation><xs:documentation>any representation of binary data - if text, line terminator is [CR][LF]</xs:documentation></xs:annotation></xs:enumeration>
</xs:restriction>
<xs:union memberTypes="
nxdl:NX_CHAR
nxdl:NX_FLOAT
nxdl:NX_INT
nxdl:NX_UINT
nxdl:NX_POSINT
nxdl:NX_NUMBER
nxdl:NX_DATE_TIME
nxdl:NX_BOOLEAN
nxdl:NX_BINARY
nxdl:ISO8601
"/>
</xs:simpleType>

<xs:simpleType name="NX_CHAR">
Expand Down
48 changes: 2 additions & 46 deletions utils/types2rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,11 @@
'''


import os, sys
import lxml.etree


def worker(nodeMatchString, section = 'units'):
if len(sys.argv) != 2:
print("usage: %s nxdlTypes.xsd" % sys.argv[0])
exit()
NXDL_TYPES_FILE = sys.argv[1]
if not os.path.exists(NXDL_TYPES_FILE):
print("Cannot find %s" % NXDL_TYPES_FILE)
exit()

tree = lxml.etree.parse(NXDL_TYPES_FILE)

output = ['.. auto-generated by %s -- DO NOT EDIT' % sys.argv[0]]
output.append('')

labels = ('term', 'description')
output.append('.. nodeMatchString : %s' % nodeMatchString)
output.append('')
db = {}

NAMESPACE = 'http://www.w3.org/2001/XMLSchema'
ns = {'xs': NAMESPACE}
root = tree.xpath('//xs:schema', namespaces=ns)[0]
s = '//xs:simpleType'
for node in tree.xpath("//xs:simpleType", namespaces=ns):
if node.get('name') == nodeMatchString:
for item in node.xpath('xs:restriction//xs:enumeration', namespaces=ns):
key = '%s' % item.get('value')
words = item.xpath('xs:annotation/xs:documentation', namespaces=ns)[0]
db[key] = words.text

print('\n'.join(output))

# this list is too long to make this a table in latex
# for two columns, a Sphinx fieldlist will do just as well
for key in sorted(db):
print('.. index:: ! %s (%s type)\n' % (key, section)) # index entry
print('.. _%s:\n' % key) # cross-reference point
print(':%s:' % key)
for line in db[key].splitlines():
print(' %s' % line)
print('')
import units2rst


if __name__ == '__main__':
worker('NAPI', section = 'data')
units2rst.worker('NAPI', section = 'data')


# NeXus - Neutron and X-ray Common Data Format
Expand Down

0 comments on commit 07eb8db

Please sign in to comment.