<typesystem package="com.trolltech.qt.xml" default-superclass="com.trolltech.qt.QtJambiObject">
    <inject-code>
        com.trolltech.qt.Utilities.loadQtLibrary("QtXml");
    </inject-code>

    <rejection class="QXmlAttributes::Attribute" />
    <rejection class="QDomNode" field-name="impl" />    
    
    <enum-type name="QDomNode::NodeType" />
    <enum-type name="QDomNode::EncodingPolicy" />
    <enum-type name="QDomImplementation::InvalidDataPolicy" />
    <enum-type name="QXmlStreamReader::Error" />
    <enum-type name="QXmlStreamReader::TokenType" />


    <value-type name="QDomAttr">
        <modify-function signature="operator=(QDomAttr)" remove="all"/>
        <modify-function signature="nodeType()const" remove="all"/>
    </value-type>   

    <value-type name="QDomCDATASection">
        <modify-function signature="operator=(QDomCDATASection)" remove="all"/>
        <modify-function signature="nodeType()const" remove="all"/>
    </value-type>

    <value-type name="QDomCharacterData">
        <modify-function signature="operator=(QDomCharacterData)" remove="all"/>
        <modify-function signature="nodeType()const" remove="all"/>
    </value-type>

    <value-type name="QDomComment">
        <modify-function signature="operator=(QDomComment)" remove="all"/>
        <modify-function signature="nodeType()const" remove="all"/>
    </value-type>

    <value-type name="QDomDocument">
        <modify-function signature="nodeType()const" remove="all"/>
        <extra-includes>
            <include file-name="com.trolltech.qt.QNativePointer.Type" location="java"/>
            <include file-name="com.trolltech.qt.core.QIODevice" location="java"/>
            <include file-name="com.trolltech.qt.core.QByteArray" location="java"/>
        </extra-includes>

        <inject-code>
    public class Result {
        private Result(boolean success, QNativePointer errorMessage, QNativePointer errorLine, QNativePointer errorColumn){
            this.success = success;
            this.errorMessage = errorMessage.stringValue();
            this.errorLine = errorLine.intValue();
            this.errorColumn = errorColumn.intValue();
        }
        public boolean success;
        public String errorMessage;
        public int errorLine;
        public int errorColumn;

        }
        </inject-code>
        
        <template name="xml.domdocument_setContent">
            public final Result setContent(%ARGUMENTS){
                QNativePointer errorStr = new QNativePointer(Type.String);
                QNativePointer errorLine = new QNativePointer(Type.Int);
                QNativePointer errorColumn = new QNativePointer(Type.Int);
                
                boolean success = setContent(%CALL_ARGUMENTS, errorStr, errorLine, errorColumn);
                return new Result(success, errorStr, errorLine, errorColumn);
            }            
        </template>

        <!--bool setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0 ); -->
        <modify-function signature="setContent(QIODevice*, bool, QString*, int*, int*)">
            <access modifier="private" />
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcContent" />
            </modify-argument>            
            <modify-argument index="3">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="4">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="5">
                <remove-default-expression />
            </modify-argument>            
        </modify-function>
        <inject-code class="java">
            <insert-template name="xml.domdocument_setContent">
                <replace from="%ARGUMENTS" to="QIODevice dev, boolean namespaceProcessing" />
                <replace from="%CALL_ARGUMENTS" to="dev, namespaceProcessing" />
            </insert-template>
        </inject-code>

        <!--bool setContent(const QByteArray& text, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0 ); -->
        <modify-function signature="setContent(QByteArray, bool, QString*, int*, int*)">
            <access modifier="private" />
            <modify-argument index="3">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="4">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="5">
                <remove-default-expression />
            </modify-argument>
            
        </modify-function>
        <inject-code class="java">
            <insert-template name="xml.domdocument_setContent">
                <replace from="%ARGUMENTS" to="QByteArray text, boolean namespaceProcessing" />
                <replace from="%CALL_ARGUMENTS" to="text, namespaceProcessing" />
            </insert-template>            
        </inject-code>

        <!--bool setContent(const QString& text, bool namespaceProcessing, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0 );-->
        <modify-function signature="setContent(QString, bool, QString*, int*, int*)">
            <access modifier="private" />
            <modify-argument index="3">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="4">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="5">
                <remove-default-expression />
            </modify-argument>            
        </modify-function>
        <inject-code class="java">
            <insert-template name="xml.domdocument_setContent">
                <replace from="%ARGUMENTS" to="String text, boolean namespaceProcessing" />
                <replace from="%CALL_ARGUMENTS" to="text, namespaceProcessing" />
            </insert-template>            
        </inject-code>

        <modify-function signature="setContent(QXmlInputSource*,QXmlReader*,QString*,int*,int*)">
            <access modifier="private" />
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcContent" />
            </modify-argument>
            <modify-argument index="3">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="4">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="5">
                <remove-default-expression />
            </modify-argument>            
        </modify-function>
        <inject-code>
            <insert-template name="xml.domdocument_setContent">
                <replace from="%ARGUMENTS" to="QXmlInputSource source, QXmlReader reader" />
                <replace from="%CALL_ARGUMENTS" to="source, reader" />
            </insert-template>
        </inject-code>

        <modify-function signature="setContent(QString,QString*,int*,int*)">
            <access modifier="private" />
            <modify-argument index="2">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="3">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="4">
                <remove-default-expression />
            </modify-argument>            
        </modify-function>
        <inject-code>
            <insert-template name="xml.domdocument_setContent">
                <replace from="%ARGUMENTS" to="String text" />
                <replace from="%CALL_ARGUMENTS" to="text" />
            </insert-template>
        </inject-code>
        
        <modify-function signature="setContent(QByteArray,QString*,int*,int*)">
            <access modifier="private" />
            <modify-argument index="2">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="3">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="4">
                <remove-default-expression />
            </modify-argument>                        
        </modify-function>
        <inject-code>
            <insert-template name="xml.domdocument_setContent">
                <replace from="%ARGUMENTS" to="QByteArray buffer" />
                <replace from="%CALL_ARGUMENTS" to="buffer" />
            </insert-template>
        </inject-code>        
        
        <modify-function signature="setContent(QIODevice*,QString*,int*,int*)">
            <access modifier="private" />
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcContent" />
            </modify-argument>            
            <modify-argument index="2">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="3">
                <remove-default-expression />
            </modify-argument>
            <modify-argument index="4">
                <remove-default-expression />
            </modify-argument>                        
        </modify-function>
        <inject-code>
            <insert-template name="xml.domdocument_setContent">
                <replace from="%ARGUMENTS" to="QIODevice dev" />
                <replace from="%CALL_ARGUMENTS" to="dev" />
            </insert-template>
        </inject-code>        
        
        <modify-function signature="operator=(QDomDocument)" remove="all"/>
    </value-type>

    <value-type name="QDomDocumentFragment">
        <modify-function signature="nodeType()const" remove="all"/>
        <modify-function signature="operator=(QDomDocumentFragment)" remove="all"/>
    </value-type>

    <value-type name="QDomDocumentType" >
        <modify-function signature="nodeType()const" remove="all"/>
        <modify-function signature="operator=(QDomDocumentType)" remove="all"/>
    </value-type>

    <value-type name="QDomEntity">
        <modify-function signature="nodeType()const" remove="all"/>
        <modify-function signature="operator=(QDomEntity)" remove="all"/>
    </value-type>

    <value-type name="QDomEntityReference">
        <modify-function signature="nodeType()const" remove="all"/>
        <modify-function signature="operator=(QDomEntityReference)" remove="all"/>
    </value-type>

    <value-type name="QDomImplementation">
        <modify-function signature="operator=(QDomImplementation)" remove="all"/>
    </value-type>

    <value-type name="QDomNamedNodeMap">
        <modify-function signature="operator=(QDomNamedNodeMap)" remove="all"/>
    </value-type>

    <value-type name="QDomNode">
        <modify-function signature="operator=(QDomNode)" remove="all"/>
        <modify-function signature="attributes()const" remove="all" />
    </value-type>

    <value-type name="QDomNodeList">
        <modify-function signature="operator=(const QDomNodeList &amp;)" remove="all"/>
    </value-type>

    <value-type name="QDomNotation">
        <modify-function signature="nodeType()const" remove="all"/>
        <modify-function signature="operator=(QDomNotation)" remove="all"/>
    </value-type>

    <value-type name="QDomProcessingInstruction">
        <modify-function signature="nodeType()const" remove="all"/>
        <modify-function signature="operator=(QDomProcessingInstruction)" remove="all"/>
    </value-type>

    <value-type name="QDomText">
        <modify-function signature="nodeType()const" remove="all"/>
        <modify-function signature="operator=(const QDomText &amp;)" remove="all"/>
    </value-type>

    <value-type name="QXmlParseException" />

    <value-type name="QXmlStreamAttribute">
        <modify-function signature="operator=(QXmlStreamAttribute)" remove="all"/>
    </value-type>

    <value-type name="QXmlStreamAttributes">
        <modify-function signature="operator+(QVector&lt;QXmlStreamAttribute>)const" remove="all"/>
        <modify-function signature="operator&lt;&lt;(QVector&lt;QXmlStreamAttribute>)" remove="all"/>
        <modify-function signature="operator&lt;&lt;(QXmlStreamAttribute)" remove="all"/>
        <modify-function signature="push_back(QXmlStreamAttribute)" remove="all"/>
        <modify-function signature="pop_back()" remove="all"/>
        <modify-function signature="push_front(QXmlStreamAttribute)" remove="all"/>
        <modify-function signature="pop_front()" remove="all"/>

        <modify-function signature="value(const QString &amp;, const QLatin1String &amp;)const">
            <remove />
        </modify-function>            
        <modify-function signature="value(const QLatin1String &amp;, const QLatin1String &amp;)const">
            <remove />
        </modify-function>            
        <modify-function signature="value(const QLatin1String &amp;)const">
            <remove />            
        </modify-function>            
    </value-type>

    <value-type name="QXmlStreamNamespaceDeclaration">
        <modify-function signature="operator=(QXmlStreamNamespaceDeclaration)" remove="all"/>
    </value-type>

    <value-type name="QXmlStreamNotationDeclaration">
        <modify-function signature="operator=(QXmlStreamNotationDeclaration)" remove="all"/>
    </value-type>

    <value-type name="QXmlStreamEntityDeclaration">
        <modify-function signature="operator=(QXmlStreamEntityDeclaration)" remove="all"/>
    </value-type>
    
    <value-type name="QXmlAttributes">  
      <modify-function signature="index(const QLatin1String&amp;) const">
        <remove/>
      </modify-function>
      <modify-function signature="value(const QLatin1String&amp;) const">
        <remove/>
      </modify-function>
    </value-type>

    <value-type name="QXmlNamespaceSupport">
        <extra-includes>
            <include file-name="com.trolltech.qt.QNativePointer" location="java" />
        </extra-includes>
        <custom-constructor>
            QXmlNamespaceSupport *clone = new QXmlNamespaceSupport;
            clone->setPrefix("", copy->uri(""));
            
            QStringList prefixes = copy->prefixes();
            for (int i=0; i&lt;prefixes.size(); ++i) 
                clone->setPrefix(prefixes.at(i), copy->uri(prefixes.at(i)));
                
            return clone;
        </custom-constructor>
        <custom-destructor>
            delete (QXmlNamespaceSupport *)copy;
        </custom-destructor>           
        <modify-function signature="processName(QString,bool,QString&amp;,QString&amp;)const">
            <access modifier="private" />
        </modify-function>
        <inject-code>
            public static class ProcessedName {
                public ProcessedName(String nsuri, String localName) {
                    this.nsuri = nsuri;
                    this.localName = localName;
                }
                public String nsuri;
                public String localName;
            }
            public ProcessedName processName(String qname, boolean isAttribute) {
                QNativePointer nsUri = new QNativePointer(QNativePointer.Type.String);
                QNativePointer localName = new QNativePointer(QNativePointer.Type.String);
                processName(qname, isAttribute, nsUri, localName);
                
                return new ProcessedName(nsUri.stringValue(), localName.stringValue());
            }
        </inject-code>
        
        <modify-function signature="splitName(QString,QString&amp;,QString&amp;)const">
            <access modifier="private" />
        </modify-function>
        <inject-code>
            public static class SplitName {
                public SplitName(String prefix, String localname) {
                    this.prefix = prefix;
                    this.localname = localname;
                }
                public String prefix;
                public String localname;
            }
            public SplitName splitName(String qname) {
                QNativePointer prefix = new QNativePointer(QNativePointer.Type.String);
                QNativePointer localName = new QNativePointer(QNativePointer.Type.String);
                splitName(qname, prefix, localName);
                
                return new SplitName(prefix.stringValue(), localName.stringValue());
            }
        </inject-code>
    </value-type>

    <value-type name="QDomElement">
        <modify-function signature="nodeType()const" remove="all"/>
        <modify-function signature="operator=(QDomElement)" remove="all"/>
        
        <template name="xml.constQString_to_constQStringRef">
            QString %out = qtjambi_to_qstring(__jni_env, (jstring) %in);
        </template>

        <modify-function signature="attributeNS(const QString, const QString &amp;, const QString &amp;) const">
            <modify-argument index="1">
                <conversion-rule class="native">
                    <insert-template name="xml.constQString_to_constQStringRef" />                            
                </conversion-rule>
            </modify-argument>
        </modify-function>
        <modify-function signature="setAttributeNS(const QString, const QString &amp;, const QString &amp;)">
            <modify-argument index="1">
                <conversion-rule class="native">
                    <insert-template name="xml.constQString_to_constQStringRef" />
                </conversion-rule>
            </modify-argument>
        </modify-function>
        <modify-function signature="setAttributeNS(const QString, const QString &amp;, int)">
            <modify-argument index="1">
                <conversion-rule class="native">
                    <insert-template name="xml.constQString_to_constQStringRef" />                    
                </conversion-rule>
            </modify-argument>
        </modify-function>
        <modify-function signature="setAttributeNS(const QString, const QString &amp;, uint)">
            <modify-argument index="1">
                <conversion-rule class="native">
                    <insert-template name="xml.constQString_to_constQStringRef" />
                </conversion-rule>
            </modify-argument>
        </modify-function>                        
        <modify-function signature="setAttributeNS(const QString, const QString &amp;, long long)">
            <modify-argument index="1">
                <conversion-rule class="native">
                    <insert-template name="xml.constQString_to_constQStringRef" />                                    
                </conversion-rule>
            </modify-argument>
        </modify-function>        
        <modify-function signature="setAttributeNS(const QString, const QString &amp;, unsigned long long)">
            <modify-argument index="1">
                <conversion-rule class="native">
                    <insert-template name="xml.constQString_to_constQStringRef" />
                </conversion-rule>
            </modify-argument>
        </modify-function>        
        <modify-function signature="setAttributeNS(const QString, const QString &amp;, double)">
            <modify-argument index="1">
                <conversion-rule class="native">
                    <insert-template name="xml.constQString_to_constQStringRef" />
                </conversion-rule>
            </modify-argument>
        </modify-function>        
        <modify-function signature="setAttribute(const QString &amp;, unsigned int)">
            <remove />
        </modify-function>
        <modify-function signature="setAttribute(const QString &amp;, unsigned long long)">
            <remove />
        </modify-function>        
        <modify-function signature="setAttributeNS(const QString, const QString &amp;, unsigned int)">
            <remove />
        </modify-function>
        <modify-function signature="setAttributeNS(const QString, const QString &amp;, unsigned long long)">
            <remove />
        </modify-function>        
        
    </value-type>
    
    <interface-type name="QXmlContentHandler">
        <modify-function signature="setDocumentLocator(QXmlLocator*)">
            <modify-argument index="1">
                <define-ownership class="shell" owner="c++" />
            </modify-argument>
        </modify-function>
    </interface-type>
    <interface-type name="QXmlDTDHandler" />
    <interface-type name="QXmlDeclHandler" />
    <interface-type name="QXmlEntityResolver" />
    <interface-type name="QXmlErrorHandler" />
    <interface-type name="QXmlLexicalHandler" />
    
    <object-type name="QXmlDefaultHandler">
        <modify-function signature="setDocumentLocator(QXmlLocator*)">
            <modify-argument index="1">
                <define-ownership class="shell" owner="c++" />
            </modify-argument>
        </modify-function>    
    </object-type>
    <object-type name="QXmlInputSource" />
    <object-type name="QXmlLocator" />        
    <object-type name="QXmlSimpleReader">
        <modify-function signature="setContentHandler(QXmlContentHandler*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcContentHandler" />
            </modify-argument>
        </modify-function>
        <modify-function signature="setDTDHandler(QXmlDTDHandler*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcDTDHandler" />
            </modify-argument>
        </modify-function>
        <modify-function signature="setDeclHandler(QXmlDeclHandler*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcDeclHandler" />
            </modify-argument>
        </modify-function>
        <modify-function signature="setEntityResolver(QXmlEntityResolver*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcEntityResolver" />
            </modify-argument>
        </modify-function>
        <modify-function signature="setErrorHandler(QXmlErrorHandler*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcErrorHandler" />
            </modify-argument>
        </modify-function>
        <modify-function signature="setLexicalHandler(QXmlLexicalHandler*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcLexicalHandler" />
            </modify-argument>
        </modify-function>
    </object-type>
    <object-type name="QXmlStreamReader">
        <modify-function signature="setDevice(QIODevice*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcDevice" />
            </modify-argument>
        </modify-function>
        <modify-function signature="clear()">
            <inject-code class="java" position="end">
                __rcDevice = null; // clear() call removes device from stream
            </inject-code>
        </modify-function>
        <modify-function signature="QXmlStreamReader(const char*)" remove="all" />
        <modify-function signature="addData(const char*)" remove="all" />
    </object-type>
    <object-type name="QXmlStreamWriter">
        <modify-function signature="QXmlStreamWriter(QString *)">
            <remove />
        </modify-function>
        <modify-function signature="QXmlStreamWriter(QByteArray *)">
            <access modifier="private" />
        </modify-function>
        <inject-code>
            public QXmlStreamWriter(com.trolltech.qt.core.QByteArray array) {
                this(array.nativePointer());
                __rcDevice = array;
            }
        </inject-code>        
        <modify-function signature="setCodec(const char *)">
            <access modifier="private" />
        </modify-function>
        <inject-code>
            public final void setCodec(String codecName) {
                setCodec(QNativePointer.createCharPointer(codecName));
                __rcCodec = null;                
            }
        </inject-code>
        <modify-function signature="setCodec(QTextCodec*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcCodec" />
            </modify-argument>
        </modify-function>
        <modify-function signature="setDevice(QIODevice*)">
            <modify-argument index="1">
                <reference-count action="set" variable-name="__rcDevice" />
            </modify-argument>
        </modify-function>
    </object-type>
    
    <object-type name="QXmlReader">
        <modify-function signature="parse(const QXmlInputSource &amp;)">
            <remove class="java" />
        </modify-function>
        
        <modify-function signature="property(QString,bool*)const">
            <remove class="java" />
        </modify-function>
        <modify-function signature="setProperty(QString,void*)">
            <remove class="java" />
        </modify-function>
                
        <modify-function signature="feature(QString,bool*)const">
            <modify-argument index="2">
                <remove-argument />
                <conversion-rule class="shell">
                    // nothing
                </conversion-rule>
                <conversion-rule class="native">
                    bool *%out = 0;
                </conversion-rule>                
            </modify-argument>
                        
            <modify-argument index="0">
                <conversion-rule class="shell">
                    bool %out = (bool) %in;
                    if (%2 != 0) *%2 = hasFeature(%1);
                </conversion-rule>
            </modify-argument>            
        </modify-function>                
    </object-type>
    
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QDomNodeList' has equals operators but no qHash() function" />
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QXmlStreamNamespaceDeclaration' has equals operators but no qHash() function" />
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QDomNamedNodeMap' has equals operators but no qHash() function" />
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QXmlStreamNotationDeclaration' has equals operators but no qHash() function" />
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QDomNode' has equals operators but no qHash() function" />
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QDomImplementation' has equals operators but no qHash() function" />
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QXmlStreamAttribute' has equals operators but no qHash() function" />
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QXmlStreamAttributes' has equals operators but no qHash() function" />
  <suppress-warning text="WARNING(MetaJavaBuilder) :: Class 'QXmlStreamEntityDeclaration' has equals operators but no qHash() function" />

</typesystem>
