]> git.saurik.com Git - apple/cf.git/blame_incremental - Parsing.subproj/CFXMLNode.h
CF-299.35.tar.gz
[apple/cf.git] / Parsing.subproj / CFXMLNode.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/* CFXMLNode.h
26 Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
27*/
28
29#if !defined(__COREFOUNDATION_CFXMLNODE__)
30#define __COREFOUNDATION_CFXMLNODE__ 1
31
32#include <CoreFoundation/CFArray.h>
33#include <CoreFoundation/CFDictionary.h>
34#include <CoreFoundation/CFString.h>
35#include <CoreFoundation/CFTree.h>
36#include <CoreFoundation/CFURL.h>
37
38#if defined(__cplusplus)
39extern "C" {
40#endif
41
42enum {
43 kCFXMLNodeCurrentVersion = 1
44};
45
46typedef const struct __CFXMLNode * CFXMLNodeRef;
47typedef CFTreeRef CFXMLTreeRef;
48
49/* An CFXMLNode describes an individual XML construct - like a tag, or a comment, or a string
50 of character data. Each CFXMLNode contains 3 main pieces of information - the node's type,
51 the data string, and a pointer to an additional data structure. The node's type ID is an enum
52 value of type CFXMLNodeTypeID. The data string is always a CFStringRef; the meaning of the
53 string is dependent on the node's type ID. The format of the additional data is also dependent
54 on the node's type; in general, there is a custom structure for each type that requires
55 additional data. See below for the mapping from type ID to meaning of the data string and
56 structure of the additional data. Note that these structures are versioned, and may change
57 as the parser changes. The current version can always be identified by kCFXMLNodeCurrentVersion;
58 earlier versions can be identified and used by passing earlier values for the version number
59 (although the older structures would have been removed from the header).
60
61 An CFXMLTree is simply a CFTree whose context data is known to be an CFXMLNodeRef. As
62 such, an CFXMLTree can be used to represent an entire XML document; the CFTree
63 provides the tree structure of the document, while the CFXMLNodes identify and describe
64 the nodes of the tree. An XML document can be parsed to a CFXMLTree, and a CFXMLTree
65 can generate the data for the equivalent XML document - see CFXMLParser.h for more
66 information on parsing XML.
67 */
68
69/* Type codes for the different possible XML nodes; this list may grow.*/
70typedef enum {
71 kCFXMLNodeTypeDocument = 1,
72 kCFXMLNodeTypeElement = 2,
73 kCFXMLNodeTypeAttribute = 3,
74 kCFXMLNodeTypeProcessingInstruction = 4,
75 kCFXMLNodeTypeComment = 5,
76 kCFXMLNodeTypeText = 6,
77 kCFXMLNodeTypeCDATASection = 7,
78 kCFXMLNodeTypeDocumentFragment = 8,
79 kCFXMLNodeTypeEntity = 9,
80 kCFXMLNodeTypeEntityReference = 10,
81 kCFXMLNodeTypeDocumentType = 11,
82 kCFXMLNodeTypeWhitespace = 12,
83 kCFXMLNodeTypeNotation = 13,
84 kCFXMLNodeTypeElementTypeDeclaration = 14,
85 kCFXMLNodeTypeAttributeListDeclaration = 15
86} CFXMLNodeTypeCode;
87
88typedef struct {
89 CFDictionaryRef attributes;
90 CFArrayRef attributeOrder;
91 Boolean isEmpty;
92 char _reserved[3];
93} CFXMLElementInfo;
94
95typedef struct {
96 CFStringRef dataString;
97} CFXMLProcessingInstructionInfo;
98
99typedef struct {
100 CFURLRef sourceURL;
101 CFStringEncoding encoding;
102} CFXMLDocumentInfo;
103
104typedef struct {
105 CFURLRef systemID;
106 CFStringRef publicID;
107} CFXMLExternalID;
108
109typedef struct {
110 CFXMLExternalID externalID;
111} CFXMLDocumentTypeInfo;
112
113typedef struct {
114 CFXMLExternalID externalID;
115} CFXMLNotationInfo;
116
117typedef struct {
118 /* This is expected to change in future versions */
119 CFStringRef contentDescription;
120} CFXMLElementTypeDeclarationInfo;
121
122typedef struct {
123 /* This is expected to change in future versions */
124 CFStringRef attributeName;
125 CFStringRef typeString;
126 CFStringRef defaultString;
127} CFXMLAttributeDeclarationInfo;
128
129typedef struct {
130 CFIndex numberOfAttributes;
131 CFXMLAttributeDeclarationInfo *attributes;
132} CFXMLAttributeListDeclarationInfo;
133
134typedef enum {
135 kCFXMLEntityTypeParameter, /* Implies parsed, internal */
136 kCFXMLEntityTypeParsedInternal,
137 kCFXMLEntityTypeParsedExternal,
138 kCFXMLEntityTypeUnparsed,
139 kCFXMLEntityTypeCharacter
140} CFXMLEntityTypeCode;
141
142typedef struct {
143 CFXMLEntityTypeCode entityType;
144 CFStringRef replacementText; /* NULL if entityType is external or unparsed */
145 CFXMLExternalID entityID; /* entityID.systemID will be NULL if entityType is internal */
146 CFStringRef notationName; /* NULL if entityType is parsed */
147} CFXMLEntityInfo;
148
149typedef struct {
150 CFXMLEntityTypeCode entityType;
151} CFXMLEntityReferenceInfo;
152
153/*
154 dataTypeCode meaning of dataString format of infoPtr
155 =========== ===================== =================
156 kCFXMLNodeTypeDocument <currently unused> CFXMLDocumentInfo *
157 kCFXMLNodeTypeElement tag name CFXMLElementInfo *
158 kCFXMLNodeTypeAttribute <currently unused> <currently unused>
159 kCFXMLNodeTypeProcessInstruction name of the target CFXMLProcessingInstructionInfo *
160 kCFXMLNodeTypeComment text of the comment NULL
161 kCFXMLNodeTypeText the text's contents NULL
162 kCFXMLNodeTypeCDATASection text of the CDATA NULL
163 kCFXMLNodeTypeDocumentFragment <currently unused> <currently unused>
164 kCFXMLNodeTypeEntity name of the entity CFXMLEntityInfo *
165 kCFXMLNodeTypeEntityReference name of the referenced entity CFXMLEntityReferenceInfo *
166 kCFXMLNodeTypeDocumentType name given as top-level element CFXMLDocumentTypeInfo *
167 kCFXMLNodeTypeWhitespace text of the whitespace NULL
168 kCFXMLNodeTypeNotation notation name CFXMLNotationInfo *
169 kCFXMLNodeTypeElementTypeDeclaration tag name CFXMLElementTypeDeclarationInfo *
170 kCFXMLNodeTypeAttributeListDeclaration tag name CFXMLAttributeListDeclarationInfo *
171*/
172
173CF_EXPORT
174CFTypeID CFXMLNodeGetTypeID(void);
175
176/* Creates a new node based on xmlType, dataString, and additionalInfoPtr. version (together with xmlType) determines the expected structure of additionalInfoPtr */
177CF_EXPORT
178CFXMLNodeRef CFXMLNodeCreate(CFAllocatorRef alloc, CFXMLNodeTypeCode xmlType, CFStringRef dataString, const void *additionalInfoPtr, CFIndex version);
179
180/* Creates a copy of origNode (which may not be NULL). */
181CF_EXPORT
182CFXMLNodeRef CFXMLNodeCreateCopy(CFAllocatorRef alloc, CFXMLNodeRef origNode);
183
184CF_EXPORT
185CFXMLNodeTypeCode CFXMLNodeGetTypeCode(CFXMLNodeRef node);
186
187CF_EXPORT
188CFStringRef CFXMLNodeGetString(CFXMLNodeRef node);
189
190CF_EXPORT
191const void *CFXMLNodeGetInfoPtr(CFXMLNodeRef node);
192
193CF_EXPORT
194CFIndex CFXMLNodeGetVersion(CFXMLNodeRef node);
195
196/* CFXMLTreeRef */
197
198/* Creates a childless, parentless tree from node */
199CF_EXPORT
200CFXMLTreeRef CFXMLTreeCreateWithNode(CFAllocatorRef allocator, CFXMLNodeRef node);
201
202/* Extracts and returns the node stored in xmlTree */
203CF_EXPORT
204CFXMLNodeRef CFXMLTreeGetNode(CFXMLTreeRef xmlTree);
205
206#if defined(__cplusplus)
207}
208#endif
209
210#endif /* ! __COREFOUNDATION_CFXMLNODE__ */
211