2002-08-04 18:00:11 +00:00
|
|
|
/** GSWTemplateParser - <title>GSWeb: Class GSWTemplateParser</title>
|
|
|
|
|
2004-03-25 08:35:25 +00:00
|
|
|
Copyright (C) 1999-2004 Free Software Foundation, Inc.
|
2002-08-04 18:00:11 +00:00
|
|
|
|
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
|
|
|
Date: Mar 1999
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
$Revision$
|
|
|
|
$Date$
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
This file is part of the GNUstep Web Library.
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
<license>
|
2000-01-22 12:49:49 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2002-08-04 18:00:11 +00:00
|
|
|
</license>
|
|
|
|
**/
|
2000-01-22 12:49:49 +00:00
|
|
|
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
#ifndef _GSWTemplateParser_h__
|
|
|
|
#define _GSWTemplateParser_h__
|
|
|
|
|
2002-10-12 11:27:50 +00:00
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
typedef enum _GSWTemplateParserType
|
|
|
|
{
|
|
|
|
GSWTemplateParserType_Default,
|
|
|
|
GSWTemplateParserType_XMLHTML,
|
|
|
|
GSWTemplateParserType_XMLHTMLNoOmittedTags,
|
|
|
|
GSWTemplateParserType_XML,
|
2004-03-25 08:35:25 +00:00
|
|
|
GSWTemplateParserType_RawHTML
|
2002-10-12 11:27:50 +00:00
|
|
|
} GSWTemplateParserType;
|
|
|
|
|
2004-03-25 08:35:25 +00:00
|
|
|
typedef enum _GSWHTMLRawParserTagType
|
|
|
|
{
|
|
|
|
GSWHTMLRawParserTagType_unknown,
|
|
|
|
GSWHTMLRawParserTagType_gsweb,
|
|
|
|
GSWHTMLRawParserTagType_wo,
|
|
|
|
GSWHTMLRawParserTagType_oog,
|
|
|
|
GSWHTMLRawParserTagType_comment
|
|
|
|
} GSWHTMLRawParserTagType;
|
|
|
|
|
|
|
|
|
|
|
|
static inline BOOL _parserIsDynamicTagType(GSWHTMLRawParserTagType tagType)
|
|
|
|
{
|
|
|
|
switch(tagType)
|
|
|
|
{
|
|
|
|
case GSWHTMLRawParserTagType_gsweb:
|
|
|
|
case GSWHTMLRawParserTagType_wo:
|
|
|
|
case GSWHTMLRawParserTagType_oog:
|
|
|
|
return YES;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NO;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline BOOL _parserIsDynamicOrCommentTagType(GSWHTMLRawParserTagType tagType)
|
|
|
|
{
|
|
|
|
switch(tagType)
|
|
|
|
{
|
|
|
|
case GSWHTMLRawParserTagType_gsweb:
|
|
|
|
case GSWHTMLRawParserTagType_wo:
|
|
|
|
case GSWHTMLRawParserTagType_oog:
|
|
|
|
case GSWHTMLRawParserTagType_comment:
|
|
|
|
return YES;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NO;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline BOOL _parserIsCommentTagType(GSWHTMLRawParserTagType tagType)
|
|
|
|
{
|
|
|
|
switch(tagType)
|
|
|
|
{
|
|
|
|
case GSWHTMLRawParserTagType_comment:
|
|
|
|
return YES;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NO;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
//====================================================================
|
2004-03-25 08:35:25 +00:00
|
|
|
/** Template Parsing protocol for new parsers **/
|
|
|
|
@protocol GSWTemplateParserDelegate
|
|
|
|
|
|
|
|
/** Called by parser when it has parsed raw text
|
|
|
|
Creates a GSWHTMLBareString element with the text
|
|
|
|
**/
|
|
|
|
-(void)parser:(GSWBaseParser*)parser
|
|
|
|
didParseText:(NSString*)text;
|
|
|
|
|
|
|
|
|
|
|
|
/** Called by parser when it has opened a dynamic tag
|
|
|
|
Creates a GSWTemporaryElement element, waiting for tag end
|
|
|
|
**/
|
|
|
|
-(void) parser:(GSWBaseParser*)parser
|
|
|
|
didParseOpeningDynamicTagOfType:(GSWHTMLRawParserTagType)tagType
|
|
|
|
withProperties:(NSDictionary*)tagProperties
|
|
|
|
templateInfo:(NSString*)templateInfo;
|
|
|
|
|
|
|
|
/** Called by parser when it has closed a dynamic tag
|
|
|
|
Creates a dynamic element from current temporary element element
|
|
|
|
**/
|
|
|
|
-(void) parser:(GSWBaseParser*)parser
|
|
|
|
didParseClosingDynamicTagOfType:(GSWHTMLRawParserTagType)tagType
|
|
|
|
withTemplateInfo:(NSString*)templateInfo;
|
|
|
|
|
|
|
|
/** Called by parser when it has parsed a comment
|
|
|
|
Creates a GSWHTMLComment with the comment text
|
|
|
|
**/
|
|
|
|
-(void) parser:(GSWBaseParser*)parser
|
|
|
|
didParseComment:(NSString*)text;
|
2010-04-16 00:18:46 +00:00
|
|
|
|
|
|
|
- (id) retain;
|
|
|
|
- (oneway void)release;
|
|
|
|
- (id)autorelease;
|
|
|
|
|
2004-03-25 08:35:25 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
/** Base template parser **/
|
|
|
|
@interface GSWTemplateParser : NSObject<GSWDeclarationParserPragmaDelegate>
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
NSString* _templateName;
|
|
|
|
NSString* _frameworkName;
|
|
|
|
NSString* _string;
|
|
|
|
NSStringEncoding _stringEncoding;
|
|
|
|
NSString* _stringPath;
|
2004-03-25 08:35:25 +00:00
|
|
|
NSString* _declarationsString;
|
2000-10-04 22:19:43 +00:00
|
|
|
NSArray* _languages;
|
2004-03-25 08:35:25 +00:00
|
|
|
NSString* _declarationsFilePath;
|
|
|
|
NSMutableSet* _processedDeclarationsFilePaths;
|
2000-10-04 22:19:43 +00:00
|
|
|
GSWElement* _template;
|
2004-03-25 08:35:25 +00:00
|
|
|
NSDictionary* _declarations;
|
|
|
|
NSMutableArray* _errorMessages; /** Template/declaration errors. If non empty, raise an exception **/
|
2001-03-11 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/GSWWOCompatibility.h/.m: added
* GSWeb.framework/GNUmakefile: added GSWWOCompatibility.h/.m
* GSWeb.framework/GSWApplication.h/m: added WOApplicationMain, handle WO/GSWeb names
* GSWeb.framework/GSWContext.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWConstants.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWDynamicURLString.m: handle WO/GSWeb names
* GSWeb.framework/GSWProjectBundle.m/.h: handle WO/GSWeb names, suppress warnings
* GSWeb.framework/GSWSession.m: handle WO/GSWeb names
* GSWeb.framework/GSWRequest.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParser.m: handle WO/GSWeb names,
added tag counts to help errors hunt
* GSWeb.framework/GSWBundle.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWResourceManager.m: handle WO/GSWeb names
* GSWeb.framework/GSWURLValuedElementData.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectAction.m: handle WO/GSWeb names
* GSWeb.framework/GSWForm.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWHyperlink.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWResourceRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWDirectActionRequestHandler.m: handle WO/GSWeb names
* GSWeb.framework/GSWActiveImage.m/.h: handle WO/GSWeb names
* GSWeb.framework/GSWBindingNameAssociation.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWBrowser.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponent.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWHTMLURLValuedElement.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWImageButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWInput.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWPopUpButton.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWString.h/.m: handle WO/GSWeb names
* GSWeb.framework/GSWAssociation.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBox.m: handle WO/GSWeb names
* GSWeb.framework/GSWCheckBoxList.m: handle WO/GSWeb names
* GSWeb.framework/GSWComponentDefinition.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButton.m: handle WO/GSWeb names
* GSWeb.framework/GSWRadioButtonList.m: handle WO/GSWeb names
* GSWeb.framework/GSWText.m: handle WO/GSWeb names
* GSWeb.framework/GSWTextField.m: handle WO/GSWeb names
* GSWeb.framework/GSWDeployedBundle.m: warnings
* GSWeb.framework/GSWeb.h: added include GSWeb/GSWSessionTimeOut.h, GSWWOCompatibility.h
* GSWeb.framework/GSWAdaptor.m: traces
* GSWeb.framework/GSWDefaultAdaptor.m: handle WO/GSWeb names, added traces
* GSWeb.framework/GSWDefaultAdaptorThread.m/.h: handle WO/GSWeb names
* GSWeb.framework/NSNonBlockingFileHandle.m: added traces
* GSWeb.framework/GSWTemplateParserANTLR.m: handle WO/GSWeb names
* GSWeb.framework/GSWTemplateParserXML.m: handle WO/GSWeb names
added tag count to help errors hunt
remove "Tag gsweb invalid" message
handle unicode strings in node content traces
remove html and body tags if they are not present in the template
* GSWeb.framework/GSWTemplateParseXML.h: added ivar _isHTMLTag, _isBodyTag
* GSWeb.framework/GSWSessionTimeOutManager.m: dealloc sessionOrderedTimeOuts instead
of deallocating 2 times sessionTimeOuts
* GSWExtensions.framework/French.lproj/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch, Encode french characters
* GSWExtensions.framework/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.html:
tag mismatch
* GSWHTMLBareString.m: handle unicode strings in description
* GSWExtensions.framework/French.lproj/GSWExceptionPage.gswc/GSWExceptionPage.html:
Encode french characters, Tag Mismatch
* GSWExtensions.framework/French.lproj/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.html:
Encode french characters
* GSWExtensions.framework/French.lproj/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.html:
Encode french characters
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.html:
Tag Mismatch
* GSWExtensions.framework/GSWExceptionPage.gswc/GSWExceptionPage.gswd:
added convertHTMLEntities for strings
* GSWeb.framework/GSWRepetition.m: added traces, fix "count" property bug, standardize ivars
* GSWeb.framework/NSObject+IVarAccess+PerformSel.m: added traces, handle underscored ivars search
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@9332 72102866-910b-0410-8b05-ffd578937521
2001-03-11 17:15:44 +00:00
|
|
|
int gswebTagN;
|
|
|
|
int tagN;
|
2000-10-04 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
+(GSWElement*)templateNamed:(NSString*)aName
|
|
|
|
inFrameworkNamed:(NSString*)aFrameworkName
|
2002-10-12 11:27:50 +00:00
|
|
|
withParserType:(GSWTemplateParserType)parserType
|
|
|
|
parserClassName:(NSString*)parserClassName
|
2000-10-04 22:19:43 +00:00
|
|
|
withString:(NSString*)HTMLString
|
|
|
|
encoding:(NSStringEncoding)encoding
|
|
|
|
fromPath:(NSString*)HTMLPath
|
2004-03-25 08:35:25 +00:00
|
|
|
declarationsString:(NSString*)declarationsString
|
2002-08-04 18:00:11 +00:00
|
|
|
languages:(NSArray*)someLanguages
|
2004-03-25 08:35:25 +00:00
|
|
|
declarationsPath:(NSString*)aDeclarationsPath;
|
2002-08-04 18:00:11 +00:00
|
|
|
+(GSWElement*)templateNamed:(NSString*)aName
|
|
|
|
inFrameworkNamed:(NSString*)aFrameworkName
|
2002-10-12 11:27:50 +00:00
|
|
|
withParserType:(GSWTemplateParserType)parserType
|
|
|
|
parserClass:(Class)parserClass
|
2000-10-04 22:19:43 +00:00
|
|
|
withString:(NSString*)HTMLString
|
|
|
|
encoding:(NSStringEncoding)encoding
|
|
|
|
fromPath:(NSString*)HTMLPath
|
2004-03-25 08:35:25 +00:00
|
|
|
declarationsString:(NSString*)declarationsString
|
2002-08-04 18:00:11 +00:00
|
|
|
languages:(NSArray*)someLanguages
|
2004-03-25 08:35:25 +00:00
|
|
|
declarationsPath:(NSString*)aDeclarationsPath;
|
2002-10-12 11:27:50 +00:00
|
|
|
+(GSWTemplateParserType)templateParserTypeFromString:(NSString*)string;
|
|
|
|
+(GSWTemplateParserType)defaultTemplateParserType;
|
2005-04-24 12:12:16 +00:00
|
|
|
|
|
|
|
+(GSWElement*)templateWithHTMLString:(NSString *)HTMLString
|
|
|
|
declarationString:(NSString *)declarationsString
|
|
|
|
languages:(NSArray *)languages;
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
-(id)initWithTemplateName:(NSString*)aName
|
|
|
|
inFrameworkName:(NSString*)aFrameworkName
|
2000-10-04 22:19:43 +00:00
|
|
|
withString:(NSString*)HTMLString
|
2002-08-04 18:00:11 +00:00
|
|
|
encoding:(NSStringEncoding)anEncoding
|
2000-10-04 22:19:43 +00:00
|
|
|
fromPath:(NSString*)HTMLPath
|
2004-03-25 08:35:25 +00:00
|
|
|
withDeclarationsString:(NSString*)declarationsString
|
|
|
|
fromPath:(NSString*)aDeclarationsPath
|
2002-08-04 18:00:11 +00:00
|
|
|
forLanguages:(NSArray*)someLanguages;
|
2004-03-25 08:35:25 +00:00
|
|
|
|
2000-10-04 22:19:43 +00:00
|
|
|
-(NSString*)logPrefix;
|
2002-11-18 11:14:55 +00:00
|
|
|
-(void)addErrorMessage:(NSString*)errorMessage;
|
|
|
|
-(void)addErrorMessageFormat:(NSString*)format
|
|
|
|
arguments:(va_list)arguments;
|
|
|
|
-(void)addErrorMessageFormat:(NSString*)format,...;
|
|
|
|
-(NSMutableArray*)errorMessages;
|
|
|
|
-(NSString*)errorMessagesAsText;
|
2000-10-04 22:19:43 +00:00
|
|
|
-(GSWElement*)template;
|
|
|
|
-(NSArray*)templateElements;
|
|
|
|
|
2004-03-25 08:35:25 +00:00
|
|
|
//GSWDeclarationParserPragmaDelegate protocol
|
|
|
|
-(NSDictionary*)includedDeclarationsFromFilePath:(NSString*)file
|
|
|
|
fromFrameworkNamed:(NSString*)frameworkName;
|
2000-10-04 22:19:43 +00:00
|
|
|
|
2004-03-25 08:35:25 +00:00
|
|
|
-(NSDictionary*)declarations;
|
|
|
|
-(void)parseDeclarations;
|
2000-01-22 12:49:49 +00:00
|
|
|
|
2004-03-25 08:35:25 +00:00
|
|
|
-(NSDictionary*)parseDeclarationsString:(NSString*)declarationsString
|
|
|
|
named:(NSString*)declarationsName
|
|
|
|
inFrameworkNamed:(NSString*)declarationsFrameworkName;
|
2010-04-16 00:18:46 +00:00
|
|
|
|
2000-01-22 12:49:49 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
#endif //_GSWTemplateParser_h__
|
2000-10-04 22:19:43 +00:00
|
|
|
|