Ejemplo n.º 1
0
    def __init__(self, path):
        """
		self.unit - the unit to which this Chapter belongs (e.g., 'Pathways & Advance Engineering')
		self.data - TabData instances for each topic
		"""
        self.data = []
        s = utils.getHtml(path)

        filename = os.path.basename(path)
        self.unit = os.path.basename(os.path.dirname(path))
        self.num, self.chapter = self.getChapterInfo(filename)
        tagPat = RegExUtils.getTagPattern('x:ExcelWorkbook')
        m = tagPat.search(s)
        if not m:
            raise Exception, "could not get TABS data from file (%s)" % path
        print 'found data'
        xml = m.group(0).replace('x:', '')  # strip x prefix from all elements

        rec = XmlRecord(xml=xml)
        rec.xpath_delimiter = '/'
        tabNodes = rec.selectNodes(
            rec.dom, "ExcelWorkbook/ExcelWorksheets/ExcelWorksheet")

        # we ignore the 'Cover sheet'
        print 'creating %d tabs' % len(tabNodes)
        for tabElement in tabNodes:
            tabData = TabData(tabElement, self.unit)
            if tabData.name.lower() != 'cover sheet':
                tabData.num = len(self) + 1
                self.append(tabData)
Ejemplo n.º 2
0
    def __init__(self, path):
        self.data = {}
        rec = XmlRecord(path=data)
        ## print rec
        rec.xpath_delimiter = "/"
        nodes = rec.selectNodes(rec.dom, 'GatheredIds/id')
        self.asnResolutionClient = AsnResolutionClient()
        print "%d nodes found" % len(nodes)

        for node in nodes:
            stdId = node.getAttribute("stdId")
            docId = node.getAttribute("docId")
            stdIds = []
            if self.has_key(docId):
                stdIds = self[docId]
            stdIds.append(stdId)
            self[docId] = stdIds
Ejemplo n.º 3
0
import re
from JloXml import XmlRecord, XmlUtils

rec = XmlRecord(path="cmp-docs/doc2.xml")
rec.xpath_delimiter = "/"

def singleNodeTester ():
	path = 'record/contributors/person[1]/@order'
	node = rec.selectSingleNode (rec.dom, path)
	if node:
		if node.nodeType == node.ATTRIBUTE_NODE:
			print "Attribute value: " + node.nodeValue
		else:
			print node.toxml()
	else:
		print 'node not found at', path

def selectNodesTester ():
	path = 'record/contributors/person'
	nodes = rec.selectNodes (rec.dom, path)
	
	if nodes:
		print '%d nodes found at %s' % (len(nodes), path)
		for node in nodes:
			if node.nodeType == node.ATTRIBUTE_NODE:
				print "Attribute value: " + node.nodeValue
			else:
				print node.toxml()
	else:
		print 'nodes not found at', path