1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef __com_sun_star_xml_sax_XFastParser_idl__
20 #define __com_sun_star_xml_sax_XFastParser_idl__
22 #include
<com
/sun
/star
/uno
/XInterface.idl
>
24 #include
<com
/sun
/star
/xml
/sax
/InputSource.idl
>
26 #include
<com
/sun
/star
/xml
/sax
/SAXException.idl
>
28 #include
<com
/sun
/star
/io
/IOException.idl
>
30 #include
<com
/sun
/star
/xml
/sax
/XFastDocumentHandler.idl
>
31 #include
<com
/sun
/star
/xml
/sax
/XFastTokenHandler.idl
>
32 #include
<com
/sun
/star
/xml
/sax
/XErrorHandler.idl
>
34 #include
<com
/sun
/star
/xml
/sax
/XDTDHandler.idl
>
36 #include
<com
/sun
/star
/xml
/sax
/XEntityResolver.idl
>
38 #include
<com
/sun
/star
/lang
/Locale.idl
>
40 #include
<com
/sun
/star
/lang
/IllegalArgumentException.idl
>
43 module com
{ module sun
{ module star
{ module xml
{ module sax
{
46 /** specifies a SAX parser that uses integer values for known XML names
47 (elements, attributes and attribute values). The parser also handles
48 namespaces and allows to have individual contexts for each XML element.
50 <p>Before parsing is possible you have to set your
51 XFastDocumentHandler using setFastDocumentHandler().
53 <p>Parsing starts with calling parseStream(). If the parser
54 finds a valid XML file with the given InputSource, it calls
55 XFastDocumentHandler::startDocument() first.
57 <p>This parser generates either "fast" events that use integer token
58 values for namespaces, elements and attributes or "unknown" events for
59 elements that are unknown.
61 <p>A namespace is unknown if the namespace URL was not registered with
64 <p>An element is unknown if no XFastTokenHandler is set
65 or if the XFastTokenHandler does not return a valid
66 identifier for the elements local name. An element is also unknown if
67 the elements local name is known but it uses a namespace that is unknown.
69 <p>Setting a XFastTokenHandler with setTokenHandler()
70 is optional, but without a XFastTokenHandler you will only
71 get unknown sax events. This can be useful if you are only interested
72 in the namespace handling and/or the context feature.
74 <p>For each element the parser sends a create child element event to the
75 elements parent context by calling
76 XFastContextHandler::createFastChildContext() for known
77 elements or XFastContextHandler::createUnknownChildContext()
79 <br>The parent context for the root element is the XFastDocumentHandler
82 <p>If the parent context returns an empty reference, no further events for
83 the element and all of its children are created.
85 <p>If a valid context is returned this context gets a start event by a call to
86 XFastContextHandler::startFastElement() for known elements or
87 XFastContextHandler::startUnknownElement() for unknown elements.
89 <p>After processing all its child elements the context gets an end event by a call to
90 XFastContextHandler::endFastElement() for known elements or
91 XFastContextHandler::endUnknownElement() for unknown elements.
93 <p>It is valid to return one instance of XFastContextHandler more
94 than once. It is even possible to only use the XFastDocumentHandler
95 by always returning a reference to itself for each create child context event.
97 <p>After the last element is processed the parser generates an end document
98 event at the XFastDocumentHandler by calling
99 XFastDocumentHandler::endDocument().
101 @see http://wiki.openoffice.org/wiki/FastParser
103 interface XFastParser
: com
::sun
::star
::uno
::XInterface
105 /** parses an XML document from a stream.
107 <p>Set the desired handlers before calling this method.</p>
109 void parseStream
( [in] InputSource aInputSource
)
110 raises
( SAXException
, com
::sun
::star
::io
::IOException
);
113 /** Application must register a document event handler to get
114 sax events for the parsed stream.
116 void setFastDocumentHandler
( [in] XFastDocumentHandler Handler
);
119 /** must be registered to translate known XML names to integer tokens.
121 void setTokenHandler
( [in] XFastTokenHandler Handler
);
124 /** registers a known namespace url with the given integer token.<br>
125 @param NamespaceURL the namespace URL.
126 @param NamespaceToken
127 an integer token that must be greater than FastToken::NAMESPACE.
129 void registerNamespace
( [in] string NamespaceURL
, [in] long NamespaceToken
)
130 raises
( com
::sun
::star
::lang
::IllegalArgumentException
);
132 /** allows an application to register an error event handler.
134 <p>Note that the error handler can throw an exception when an error or
135 warning occurs. Note that an exception is thrown by the parser when
136 an unrecoverable (fatal) error occurs.</p>
138 void setErrorHandler
( [in] XErrorHandler Handler
);
140 /** allows an application to register a DTD-Handler.
142 void setEntityResolver
( [in] XEntityResolver Resolver
);
144 /** sets a locale specified for localization of warnings and error messages.
146 <p>Set the language of the error messages. Useful when the parsing
147 errors will be presented to the user.</p>
149 void setLocale
( [in] com
::sun
::star
::lang
::Locale locale
);
151 /** Gets the namespace url string.
153 string getNamespaceURL
( [in] string prefix
)
154 raises
( com
::sun
::star
::lang
::IllegalArgumentException
);
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */