fixed recursive_children cvterm function, and added tests for parents and children
[cxgn-corelibs.git] / lib / MOBY / MobyXMLConstants.pm
blobe00b7d2c25a5b7e96c9b5580dda932c1ea5380fa
1 package MOBY::MobyXMLConstants;
2 use strict;
3 use vars qw( $VERSION @ISA @EXPORT @NodeNames);
5 BEGIN {
6 @ISA = qw( Exporter );
7 #########################################################
8 #The purpose of this module is to emulate some of the #
9 #functionality found in the XML::DOM::Node module. Upon #
10 #switching parsers, it was apparent that some subs didnt#
11 #exist in LibXML and so they have been recreated here. #
12 #########################################################
13 # Constants for XML::DOM Node types
14 @EXPORT = qw(
15 UNKNOWN_NODE
16 ELEMENT_NODE
17 ATTRIBUTE_NODE
18 TEXT_NODE
19 CDATA_SECTION_NODE
20 ENTITY_REFERENCE_NODE
21 ENTITY_NODE
22 PROCESSING_INSTRUCTION_NODE
23 COMMENT_NODE
24 DOCUMENT_NODE
25 DOCUMENT_TYPE_NODE
26 DOCUMENT_FRAGMENT_NODE
27 NOTATION_NODE
28 ELEMENT_DECL_NODE
29 ATT_DEF_NODE
30 XML_DECL_NODE
31 ATTLIST_DECL_NODE
32 getNodeTypeName
36 #---- Constant definitions
37 # Node types
38 sub UNKNOWN_NODE () { 0 } # not in the DOM Spec
39 sub ELEMENT_NODE () { 1 }
40 sub ATTRIBUTE_NODE () { 2 }
41 sub TEXT_NODE () { 3 }
42 sub CDATA_SECTION_NODE () { 4 }
43 sub ENTITY_REFERENCE_NODE () { 5 }
44 sub ENTITY_NODE () { 6 }
45 sub PROCESSING_INSTRUCTION_NODE () { 7 }
46 sub COMMENT_NODE () { 8 }
47 sub DOCUMENT_NODE () { 9 }
48 sub DOCUMENT_TYPE_NODE () { 10 }
49 sub DOCUMENT_FRAGMENT_NODE () { 11 }
50 sub NOTATION_NODE () { 12 }
51 sub ELEMENT_DECL_NODE () { 13 } # not in the DOM Spec
52 sub ATT_DEF_NODE () { 14 } # not in the DOM Spec
53 sub XML_DECL_NODE () { 15 } # not in the DOM Spec
54 sub ATTLIST_DECL_NODE () { 16 } # not in the DOM Spec
55 @NodeNames = (
56 "UNKNOWN_NODE", # not in the DOM Spec!
57 "XML_ELEMENT_NODE",
58 "XML_ATTRIBUTE_NODE",
59 "XML_TEXT_NODE",
60 "XML_CDATA_SECTION_NODE",
61 "XML_ENTITY_REF_NODE",
62 "XML_ENTITY_NODE",
63 "XML_PI_NODE",
64 "XML_COMMENT_NODE",
65 "XML_DOCUMENT_NODE",
66 "XML_DOCUMENT_TYPE_NODE",
67 "XML_DOCUMENT_FRAG_NODE",
68 "XML_NOTATION_NODE",
69 "XML_ELEMENT_DECL_NODE",
70 "XML_ATT_DEF_NODE",
71 "XML_DECL_NODE",
72 "XML_ATTLIST_DECL_NODE"
75 # this sub takes in a LibXML::Node and outputs the nodeTypeName.
76 sub getNodeTypeName {
77 $NodeNames[ $_[0]->nodeType ];