2 * Copyright (c) 2011 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 Copyright (c) 1998-2011, Apple Inc. All rights reserved.
28 /* CFXMLParser (and thus CFXMLNode) are deprecated. Clients should be aware of the fact that CFXMLParser has
29 some serious deficiencies in terms of both performance and standards compliance and should migrate their
30 XML parsing to NSXMLParser, NSXMLDocument, or other XML parsing technologies.
33 #if !defined(__COREFOUNDATION_CFXMLNODE__)
34 #define __COREFOUNDATION_CFXMLNODE__ 1
36 #include <CoreFoundation/CFArray.h>
37 #include <CoreFoundation/CFDictionary.h>
38 #include <CoreFoundation/CFString.h>
39 #include <CoreFoundation/CFTree.h>
40 #include <CoreFoundation/CFURL.h>
45 kCFXMLNodeCurrentVersion
= 1
48 typedef const struct __CFXMLNode
* CFXMLNodeRef
;
49 typedef CFTreeRef CFXMLTreeRef
;
51 /* An CFXMLNode describes an individual XML construct - like a tag, or a comment, or a string
52 of character data. Each CFXMLNode contains 3 main pieces of information - the node's type,
53 the data string, and a pointer to an additional data structure. The node's type ID is an enum
54 value of type CFXMLNodeTypeID. The data string is always a CFStringRef; the meaning of the
55 string is dependent on the node's type ID. The format of the additional data is also dependent
56 on the node's type; in general, there is a custom structure for each type that requires
57 additional data. See below for the mapping from type ID to meaning of the data string and
58 structure of the additional data. Note that these structures are versioned, and may change
59 as the parser changes. The current version can always be identified by kCFXMLNodeCurrentVersion;
60 earlier versions can be identified and used by passing earlier values for the version number
61 (although the older structures would have been removed from the header).
63 An CFXMLTree is simply a CFTree whose context data is known to be an CFXMLNodeRef. As
64 such, an CFXMLTree can be used to represent an entire XML document; the CFTree
65 provides the tree structure of the document, while the CFXMLNodes identify and describe
66 the nodes of the tree. An XML document can be parsed to a CFXMLTree, and a CFXMLTree
67 can generate the data for the equivalent XML document - see CFXMLParser.h for more
68 information on parsing XML.
71 /* Type codes for the different possible XML nodes; this list may grow.*/
73 kCFXMLNodeTypeDocument
= 1,
74 kCFXMLNodeTypeElement
= 2,
75 kCFXMLNodeTypeAttribute
= 3,
76 kCFXMLNodeTypeProcessingInstruction
= 4,
77 kCFXMLNodeTypeComment
= 5,
78 kCFXMLNodeTypeText
= 6,
79 kCFXMLNodeTypeCDATASection
= 7,
80 kCFXMLNodeTypeDocumentFragment
= 8,
81 kCFXMLNodeTypeEntity
= 9,
82 kCFXMLNodeTypeEntityReference
= 10,
83 kCFXMLNodeTypeDocumentType
= 11,
84 kCFXMLNodeTypeWhitespace
= 12,
85 kCFXMLNodeTypeNotation
= 13,
86 kCFXMLNodeTypeElementTypeDeclaration
= 14,
87 kCFXMLNodeTypeAttributeListDeclaration
= 15
89 typedef CFIndex CFXMLNodeTypeCode
;
92 CFDictionaryRef attributes
;
93 CFArrayRef attributeOrder
;
99 CFStringRef dataString
;
100 } CFXMLProcessingInstructionInfo
;
104 CFStringEncoding encoding
;
109 CFStringRef publicID
;
113 CFXMLExternalID externalID
;
114 } CFXMLDocumentTypeInfo
;
117 CFXMLExternalID externalID
;
121 /* This is expected to change in future versions */
122 CFStringRef contentDescription
;
123 } CFXMLElementTypeDeclarationInfo
;
126 /* This is expected to change in future versions */
127 CFStringRef attributeName
;
128 CFStringRef typeString
;
129 CFStringRef defaultString
;
130 } CFXMLAttributeDeclarationInfo
;
133 CFIndex numberOfAttributes
;
134 CFXMLAttributeDeclarationInfo
*attributes
;
135 } CFXMLAttributeListDeclarationInfo
;
138 kCFXMLEntityTypeParameter
, /* Implies parsed, internal */
139 kCFXMLEntityTypeParsedInternal
,
140 kCFXMLEntityTypeParsedExternal
,
141 kCFXMLEntityTypeUnparsed
,
142 kCFXMLEntityTypeCharacter
144 typedef CFIndex CFXMLEntityTypeCode
;
147 CFXMLEntityTypeCode entityType
;
148 CFStringRef replacementText
; /* NULL if entityType is external or unparsed */
149 CFXMLExternalID entityID
; /* entityID.systemID will be NULL if entityType is internal */
150 CFStringRef notationName
; /* NULL if entityType is parsed */
154 CFXMLEntityTypeCode entityType
;
155 } CFXMLEntityReferenceInfo
;
158 dataTypeCode meaning of dataString format of infoPtr
159 =========== ===================== =================
160 kCFXMLNodeTypeDocument <currently unused> CFXMLDocumentInfo *
161 kCFXMLNodeTypeElement tag name CFXMLElementInfo *
162 kCFXMLNodeTypeAttribute <currently unused> <currently unused>
163 kCFXMLNodeTypeProcessingInstruction name of the target CFXMLProcessingInstructionInfo *
164 kCFXMLNodeTypeComment text of the comment NULL
165 kCFXMLNodeTypeText the text's contents NULL
166 kCFXMLNodeTypeCDATASection text of the CDATA NULL
167 kCFXMLNodeTypeDocumentFragment <currently unused> <currently unused>
168 kCFXMLNodeTypeEntity name of the entity CFXMLEntityInfo *
169 kCFXMLNodeTypeEntityReference name of the referenced entity CFXMLEntityReferenceInfo *
170 kCFXMLNodeTypeDocumentType name given as top-level element CFXMLDocumentTypeInfo *
171 kCFXMLNodeTypeWhitespace text of the whitespace NULL
172 kCFXMLNodeTypeNotation notation name CFXMLNotationInfo *
173 kCFXMLNodeTypeElementTypeDeclaration tag name CFXMLElementTypeDeclarationInfo *
174 kCFXMLNodeTypeAttributeListDeclaration tag name CFXMLAttributeListDeclarationInfo *
178 CFTypeID
CFXMLNodeGetTypeID(void);
180 /* Creates a new node based on xmlType, dataString, and additionalInfoPtr. version (together with xmlType) determines the expected structure of additionalInfoPtr */
182 CFXMLNodeRef
CFXMLNodeCreate(CFAllocatorRef alloc
, CFXMLNodeTypeCode xmlType
, CFStringRef dataString
, const void *additionalInfoPtr
, CFIndex version
);
184 /* Creates a copy of origNode (which may not be NULL). */
186 CFXMLNodeRef
CFXMLNodeCreateCopy(CFAllocatorRef alloc
, CFXMLNodeRef origNode
);
189 CFXMLNodeTypeCode
CFXMLNodeGetTypeCode(CFXMLNodeRef node
);
192 CFStringRef
CFXMLNodeGetString(CFXMLNodeRef node
);
195 const void *CFXMLNodeGetInfoPtr(CFXMLNodeRef node
);
198 CFIndex
CFXMLNodeGetVersion(CFXMLNodeRef node
);
202 /* Creates a childless, parentless tree from node */
204 CFXMLTreeRef
CFXMLTreeCreateWithNode(CFAllocatorRef allocator
, CFXMLNodeRef node
);
206 /* Extracts and returns the node stored in xmlTree */
208 CFXMLNodeRef
CFXMLTreeGetNode(CFXMLTreeRef xmlTree
);
212 #endif /* ! __COREFOUNDATION_CFXMLNODE__ */