/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is ETNA Relax NG validator. * * The Initial Developer of the Original Code is The Connexions Project. * * Portions created by the Initial Developer are Copyright (C) 2004-2006 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Laurent Jouanneau , Original author * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsISupports.idl" #include "nsIMutableArray.idl" #include "nsIDOMDocument.idl" #include "diIValidationSchema.idl" interface diISchemaPattern; [scriptable, uuid(dced6725-8529-47ac-9c37-937e62fcb4f8)] interface diISchemaParserError : nsISupports { attribute short code; attribute nsIDOMNode node; attribute ACString fileUrl; }; [uuid(1a2fdb3d-b6ea-4e30-907e-e322247e93d1)] interface diISchemaParserDefine : nsISupports { attribute AString name; attribute short combinationMode; attribute nsIMutableArray patternList; attribute nsIMutableArray refList; attribute nsIMutableArray strRefList; }; /** * this interface represents a schema parser */ [scriptable, uuid(aa494709-818b-4e51-aeb0-b5ffdf69620a)] interface diISchemaParser : nsISupports { /** * parse a DOM tree that contains a schema * @param aSchemaElement the DOM tree to parse * @param aBaseUri the base uri of the document. it is needed to load correctly sub-schema * @return a schema object that contains all information about the schema. could be null if isMasterParser = false */ diIValidationSchema parseSchema (in nsIDOMElement aSchemaElement, in ACString aBaseUri); /** * parse a xml file that contains a relax ng schema * @param aUrl the URI of the file * @return a schema object that contains all information about the schema. could be null if isMasterParser = false */ diIValidationSchema parseSchemaFile (in ACString aUrl); /** * ------------------------------------------------------------------------------ * Following methods and properties must be used only by diISchemaPattern objects * ------------------------------------------------------------------------------ */ const unsigned short ELEMENT_MODE = 1; const unsigned short ATTRIBUTE_MODE = 2; const unsigned short DATA_MODE = 3; /** * this method is responsible to analyse a DOMElement in the schema * @param currentDomElt the DOMNode in the schema to analyse * @return a pattern object that generates a piece of the graph */ [noscript] diISchemaPattern getPattern (in nsIDOMNode currentDomElt); /** * The parsing mode says if the parser is analysing an element pattern, * an attribute pattern or one of data pattern. * it contains one of the *_MODE constants */ [noscript] readonly attribute short parsingMode; [noscript] void SetNewParsingMode(in short aMode); [noscript] void SetPreviousParsingMode(); readonly attribute diISchemaParserError error; [noscript] void setError( in short errorCode); /** * the namespaceUri that is valid in the current pattern */ [noscript] readonly attribute AString currentNamespaceURI; /** * the datatype library that is valid in the current pattern */ [noscript] readonly attribute AString currentDatatypeLibrary; const unsigned short UNKNOW_COMBINATION_MODE = 0; const unsigned short CHOICE_COMBINATION_MODE = 1; const unsigned short INTERLEAVE_COMBINATION_MODE = 2; /** * add a "define" graph to the schema */ [noscript] void addDefineFromPattern(in AString aName, in short aCombinationMode, in diISchemaPattern aPattern); /** * add a "Ref" graph to the schema */ [noscript] void addRefDefineFromPattern(in AString aName, in diISchemaGraphRefNode aRefNode, in diIStringGraphRefNode aStrRefNode); /** * add a "parentRef" graph to the schema */ [noscript] void addParentRefDefineFromPattern(in AString aName, in diISchemaGraphRefNode aRefNode, in diIStringGraphRefNode aStrRefNode); /** * add a "element" graph to the schema */ [noscript] void addElementFromPattern(in diISchemaElementProperties aElementDatas); /** * because of an include or externalRef pattern in RelaxNG, we have to * we have to parse the subschema. The interface provide the way to parse them. * call useSubSchema to parse a sub schema, and then endOfUsingSubSchema. * Between the two call, you can add other pattern to replace some of pattern of the sub schema, * by call add*FromPattern.. * @param aUrl the uri of the schema. can be relative to the aUrl given to parseSchema* method * @param aMergedSchema says if the readed schema should be merge (include pattern) or juste append (externalRef pattern) to the current schema * @param aRefNode for externalRef & grammar pattern */ [noscript] void useSubSchema(in AString aUrl, in boolean aMergedSchema, in diISchemaGraphRefNode aRefNode); /** * must be call after useSubSchema * @param aRefStartNode a node that refer to the included schema (can be null in the case of include pattern */ [noscript] void endOfUsingSubSchema(); [noscript] ACString getAbsoluteUri( in ACString aRelativeUri); [noscript] void loadStringBundle(in AString aUrl); [noscript] AString getLocalString( in AString aKey); [noscript] short getNsAndLnFromName(in AString aQualifiedName, in boolean aForAttr, out AString aLocalName, out AString aNamespaceURI); [noscript] void checkIllegalAttributes(in nsIDOMElement aPatternElement, in AString aExceptAttr1, in AString aExceptAttr2); };