2002-08-04 18:00:11 +00:00
|
|
|
/** GSWTemplateParserANTLR.h - <title>GSWeb: Class GSWTemplateParserANTLR</title>
|
|
|
|
|
|
|
|
Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
|
|
|
Date: Mar 1999
|
2000-10-04 22:19:43 +00:00
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
$Revision$
|
|
|
|
$Date$
|
|
|
|
|
2000-10-04 22:19:43 +00:00
|
|
|
This file is part of the GNUstep Web Library.
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
<license>
|
2000-10-04 22:19:43 +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-10-04 22:19:43 +00:00
|
|
|
|
|
|
|
static char rcsId[] = "$Id$";
|
|
|
|
|
2000-10-30 15:36:50 +00:00
|
|
|
#include <GSWeb/GSWeb.h>
|
2000-10-04 22:19:43 +00:00
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
@implementation GSWTemplateParserANTLR
|
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
DESTROY(_tagsNames);
|
|
|
|
DESTROY(_tagsAttrs);
|
|
|
|
[super dealloc];
|
|
|
|
};
|
|
|
|
-(NSArray*)templateElements
|
|
|
|
{
|
|
|
|
NSArray* elements=nil;
|
|
|
|
id<NSObject,ANTLRAST> htmlAST=nil;
|
|
|
|
NSAutoreleasePool* arpParse=nil;
|
|
|
|
ANTLRTextInputStreamString* htmlStream=nil;
|
|
|
|
GSWHTMLLexer* htmlLexer=nil;
|
|
|
|
ANTLRTokenBuffer* htmlTokenBuffer=nil;
|
|
|
|
GSWHTMLParser* htmlParser=nil;
|
|
|
|
LOGObjectFnStart();
|
|
|
|
NSDebugMLLog(@"low",@"template named:%@ frameworkName:%@ pageDefString=%@",
|
|
|
|
_templateName,
|
|
|
|
_frameworkName,
|
|
|
|
_definitionsString);
|
|
|
|
//TODO remove
|
|
|
|
/*
|
|
|
|
[ANTLRCharBuffer setTraceFlag_LA:YES];
|
|
|
|
[ANTLRCharScanner setTraceFlag_LA:YES];
|
|
|
|
[ANTLRLLkParser setTraceFlag_LA:YES];
|
|
|
|
[ANTLRTokenBuffer setTraceFlag_LA:YES];
|
|
|
|
*/
|
|
|
|
htmlStream=[[ANTLRTextInputStreamString newWithString:_string]
|
|
|
|
autorelease];
|
|
|
|
htmlLexer=[[[GSWHTMLLexer alloc]initWithTextStream:htmlStream]
|
|
|
|
autorelease];
|
|
|
|
htmlTokenBuffer=[ANTLRTokenBuffer tokenBufferWithTokenizer:htmlLexer];
|
|
|
|
htmlParser=[[[GSWHTMLParser alloc] initWithTokenBuffer:htmlTokenBuffer]
|
|
|
|
autorelease];
|
|
|
|
NSDebugMLLog(@"low",@"template named:%@ HTMLString=%@",
|
|
|
|
_templateName,
|
|
|
|
_string);
|
|
|
|
arpParse=[NSAutoreleasePool new];
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[htmlParser document];
|
|
|
|
if ([htmlParser isError])
|
|
|
|
{
|
|
|
|
LOGError(@"Parser Errors : %@",[htmlParser errors]);
|
|
|
|
ExceptionRaise(@"GSWTemplateParser",
|
|
|
|
@"GSWTemlateParser: Errors in HTML parsing template named %@: %@\nAST:\n%@",
|
|
|
|
_templateName,
|
|
|
|
[htmlParser errors],
|
|
|
|
[htmlParser AST]);
|
|
|
|
};
|
|
|
|
htmlAST=[htmlParser AST];
|
|
|
|
NSDebugMLLog0(@"low",@"HTML Parse OK!");
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGError(@"template named:%@ HTML Parse failed!",_templateName);
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,@"In [htmlParser document]... template named:%@ HTML Parse failed!",_templateName);
|
|
|
|
[localException retain];
|
|
|
|
DESTROY(arpParse);
|
|
|
|
[localException autorelease];
|
|
|
|
[localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
NSDebugMLLog0(@"low",@"arpParse infos:\n");
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if ([NSThread currentThread])
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"low",@"thread current_pool=%@",
|
|
|
|
[NSThread currentThread]->_autorelease_vars.current_pool);
|
|
|
|
NSDebugMLLog(@"low",@"thread current_pool _parentAutoreleasePool=%@",
|
|
|
|
[[NSThread currentThread]->_autorelease_vars.current_pool _parentAutoreleasePool]);
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
NSDebugMLLog0(@"low",@"DESTROY(arpParse)\n");
|
|
|
|
[htmlAST retain];
|
|
|
|
DESTROY(arpParse);
|
|
|
|
arpParse=[NSAutoreleasePool new];
|
|
|
|
[htmlAST autorelease];
|
|
|
|
NSDebugMLLog0(@"low",@"DESTROYED(arpParse)\n");
|
|
|
|
if (htmlAST)
|
|
|
|
{
|
|
|
|
_tagsNames=[[NSMutableDictionary dictionary] retain];
|
|
|
|
_tagsAttrs=[[NSMutableDictionary dictionary] retain];
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
elements=[self createElementsStartingWithAST:&htmlAST
|
|
|
|
stopOnTagNamed:nil];
|
|
|
|
NSDebugMLLog(@"low",@"template named:%@ _template=%@",
|
|
|
|
_templateName,
|
|
|
|
elements);
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
LOGSeriousError(@"template named:%@ createElements failed!",
|
|
|
|
_templateName);
|
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
|
|
|
@"In createElementsStartingWithAST...");
|
|
|
|
[localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
};
|
|
|
|
NSDebugMLLog0(@"low",@"ARP infos:\n");
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if ([NSThread currentThread])
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"low",@"thread current_pool=%@",
|
|
|
|
[NSThread currentThread]->_autorelease_vars.current_pool);
|
|
|
|
NSDebugMLLog(@"low",@"thread current_pool _parentAutoreleasePool=%@",
|
|
|
|
[[NSThread currentThread]->_autorelease_vars.current_pool _parentAutoreleasePool]);
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
[elements retain];
|
|
|
|
NSDebugMLLog0(@"low",@"DESTROY(arp)\n");
|
|
|
|
DESTROY(arpParse);
|
|
|
|
NSDebugMLLog0(@"low",@"DESTROYED(arp)\n");
|
|
|
|
[elements autorelease];
|
|
|
|
NSDebugMLLog0(@"low",@"Display Template\n");
|
|
|
|
NSDebugMLLog(@"low",@"template named:%@ elements=%@",
|
|
|
|
_templateName,
|
|
|
|
elements);
|
|
|
|
LOGClassFnStop();
|
|
|
|
return elements;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
-(BOOL)parseTag:(ANTLRDefAST)anAST
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
BOOL htmlAttrParseOK=YES;
|
2002-08-04 18:00:11 +00:00
|
|
|
NSString* tagName=[_tagsNames objectForKey:[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]; //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
LOGClassFnStart();
|
|
|
|
if (!tagName
|
2002-08-04 18:00:11 +00:00
|
|
|
&& ([anAST tokenType]==GSWHTMLTokenType_OPENTAG
|
|
|
|
|| [anAST tokenType]==GSWHTMLTokenType_CLOSETAG))
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
NSAutoreleasePool* arpParse=nil;
|
|
|
|
ANTLRTextInputStreamString* _tagStream=[[[ANTLRTextInputStreamString alloc]
|
2002-08-04 18:00:11 +00:00
|
|
|
initWithString:[anAST text]]
|
2000-10-04 22:19:43 +00:00
|
|
|
autorelease];
|
|
|
|
GSWHTMLAttrLexer* htmlAttrLexer=[[[GSWHTMLAttrLexer alloc]
|
|
|
|
initWithTextStream:_tagStream]
|
|
|
|
autorelease];
|
|
|
|
ANTLRTokenBuffer* htmlAttrTokenBuffer=[ANTLRTokenBuffer tokenBufferWithTokenizer:htmlAttrLexer];
|
|
|
|
GSWHTMLAttrParser* _tagParser=[[[GSWHTMLAttrParser alloc] initWithTokenBuffer:htmlAttrTokenBuffer]
|
|
|
|
autorelease];
|
|
|
|
NSString* tagName=nil;
|
|
|
|
NSDictionary* tagAttrs=nil;
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"PARSE:[%@]",[anAST text]);
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"stream:[%@]",_tagStream);
|
|
|
|
htmlAttrParseOK=NO;
|
|
|
|
arpParse=[NSAutoreleasePool new];
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
[_tagParser tag];
|
|
|
|
if ([_tagParser isError])
|
|
|
|
{
|
|
|
|
LOGError(@"Parser Errors : %@",[_tagParser errors]);
|
|
|
|
ExceptionRaise(@"GSWTemplateParser",
|
|
|
|
@"GSWTemlateParser: Errors in HTML Tag parsing: %@",
|
|
|
|
[_tagParser errors]);
|
|
|
|
};
|
|
|
|
tagName=[_tagParser tagName];
|
|
|
|
tagAttrs=[_tagParser attributes];
|
|
|
|
NSDebugMLLog(@"low",@"tagName=%@ tagAttrs=%@",
|
|
|
|
tagName,
|
|
|
|
tagAttrs);
|
|
|
|
htmlAttrParseOK=YES;
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
htmlAttrParseOK=NO;
|
2002-08-04 18:00:11 +00:00
|
|
|
LOGError(@"PARSE PB:[%@]",[anAST text]);//TODO
|
2000-10-04 22:19:43 +00:00
|
|
|
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
|
|
|
@"In [_tagParser tag]...");
|
|
|
|
[localException raise];
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER;
|
|
|
|
NSDebugMLLog0(@"low",@"arpParse infos:\n");
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if ([NSThread currentThread])
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"low",@"thread current_pool=%@",
|
|
|
|
[NSThread currentThread]->_autorelease_vars.current_pool);
|
|
|
|
NSDebugMLLog(@"low",@"thread current_pool _parentAutoreleasePool=%@",
|
|
|
|
[[NSThread currentThread]->_autorelease_vars.current_pool _parentAutoreleasePool]);
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
NSDebugMLLog0(@"low",@"DESTROY(arpParse)\n");
|
|
|
|
DESTROY(arpParse);
|
|
|
|
NSDebugMLLog0(@"low",@"DESTROYED(arpParse)\n");
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"END PARSE:[%@]",[anAST text]);
|
2000-10-04 22:19:43 +00:00
|
|
|
|
|
|
|
if (htmlAttrParseOK && tagName)
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"low",@"tagName:[%@]",tagName);
|
|
|
|
if ([tagName hasPrefix:@"\""] && [tagName hasSuffix:@"\""])
|
2002-09-22 14:27:04 +00:00
|
|
|
tagName=[[tagName stringByDeletingPrefix:@"\""]stringByDeletingSuffix:@"\""];
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"Add tagName:[%@]",
|
|
|
|
tagName);
|
|
|
|
[_tagsNames setObject:tagName
|
2002-08-04 18:00:11 +00:00
|
|
|
forKey:[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]; //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"Verify tagName=%@",
|
2002-08-04 18:00:11 +00:00
|
|
|
[_tagsNames objectForKey:[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]); //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"Add tagsAttrs:[%@]",
|
|
|
|
tagAttrs);
|
|
|
|
if (tagAttrs)
|
|
|
|
{
|
|
|
|
[_tagsAttrs setObject:tagAttrs
|
2002-08-04 18:00:11 +00:00
|
|
|
forKey:[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]; //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"Verify tagAttrs=%@",
|
2002-08-04 18:00:11 +00:00
|
|
|
[_tagsAttrs objectForKey:[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]); //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
LOGClassFnStop();
|
|
|
|
return htmlAttrParseOK;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
-(NSString*)getTagNameFor:(ANTLRDefAST)anAST
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
NSString* tagName=[_tagsNames objectForKey:
|
|
|
|
[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]; //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
LOGClassFnStart();
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"[%@]",[anAST text]);
|
2000-10-04 22:19:43 +00:00
|
|
|
if (!tagName)
|
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
BOOL htmlAttrParseOK=[self parseTag:anAST];
|
2000-10-04 22:19:43 +00:00
|
|
|
if (htmlAttrParseOK)
|
2002-08-04 18:00:11 +00:00
|
|
|
tagName=[_tagsNames objectForKey:
|
|
|
|
[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]; //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
};
|
|
|
|
NSDebugMLLog(@"low",@"tagName:[%@]",tagName);
|
|
|
|
LOGClassFnStop();
|
|
|
|
return tagName;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
-(NSDictionary*)getTagAttrsFor:(ANTLRDefAST)anAST
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
NSDictionary* tagAttrs=[_tagsAttrs objectForKey:
|
2002-08-04 18:00:11 +00:00
|
|
|
[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]; //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
LOGClassFnStart();
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"[%@]",[anAST text]);
|
2000-10-04 22:19:43 +00:00
|
|
|
if (!tagAttrs)
|
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
BOOL htmlAttrParseOK=[self parseTag:anAST];
|
2000-10-04 22:19:43 +00:00
|
|
|
if (htmlAttrParseOK)
|
|
|
|
tagAttrs=[_tagsAttrs objectForKey:
|
2002-08-04 18:00:11 +00:00
|
|
|
[NSNumber numberWithUnsignedLong:(unsigned long)anAST]]; //TODO bad hack
|
2000-10-04 22:19:43 +00:00
|
|
|
};
|
|
|
|
NSDebugMLLog(@"low",@"tagAttrs:[%@]",tagAttrs);
|
|
|
|
LOGClassFnStop();
|
|
|
|
return tagAttrs;
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2002-08-04 18:00:11 +00:00
|
|
|
-(NSArray*)createElementsStartingWithAST:(ANTLRDefAST*)anAST
|
|
|
|
stopOnTagNamed:(NSString*)stopTagName
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
NSMutableArray* elements=[NSMutableArray array];
|
|
|
|
ANTLRDefAST currentAST=*anAST;
|
2000-10-04 22:19:43 +00:00
|
|
|
BOOL end=NO;
|
|
|
|
BOOL inHTMLBareString=NO;
|
|
|
|
NSMutableString* htmlBareString=nil;
|
|
|
|
LOGClassFnStart();
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"stopTagName:[%@]",stopTagName);
|
|
|
|
while(currentAST && !end)
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
GSWElement* element=nil;
|
|
|
|
NSString* tagName=nil;
|
|
|
|
NSDictionary* tagAttrs=nil;
|
|
|
|
BOOL stopBareString=NO;
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"[currentAST: text=[%@] Type=%d",
|
|
|
|
[currentAST text],
|
|
|
|
[currentAST tokenType]);
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"end=%s inHTMLBareString=%s stopBareString=%s",
|
|
|
|
end ? "YES" : "NO",
|
|
|
|
inHTMLBareString ? "YES" : "NO",
|
|
|
|
stopBareString ? "YES" : "NO");
|
|
|
|
|
2002-08-04 18:00:11 +00:00
|
|
|
if ([currentAST tokenType]==GSWHTMLTokenType_OPENTAG
|
|
|
|
|| [currentAST tokenType]==GSWHTMLTokenType_CLOSETAG)
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
tagName=[self getTagNameFor:currentAST];
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"Result tagName:[%@]",tagName);
|
|
|
|
if (!tagName)
|
|
|
|
{
|
|
|
|
LOGError0(@"");//TODO
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"[currentAST tokenType]=%d",(int)[currentAST tokenType]);
|
|
|
|
if ([currentAST tokenType]==GSWHTMLTokenType_OPENTAG)
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
NSDebugMLLog0(@"low",@"Found Open Tag");
|
2002-08-04 18:00:11 +00:00
|
|
|
tagAttrs=[self getTagAttrsFor:currentAST];
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"tagAttrs=%@",tagAttrs);
|
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
|
|
|
if ([tagName caseInsensitiveCompare:GSWTag_Name[GSWNAMES_INDEX]]==NSOrderedSame
|
|
|
|
|| [tagName caseInsensitiveCompare:GSWTag_Name[WONAMES_INDEX]]==NSOrderedSame)
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
NSDebugMLLog0(@"low",@"Found GSWeb Tag");
|
|
|
|
NSDebugMLLog(@"low",@"tagAttrs=%@",
|
|
|
|
tagAttrs);
|
|
|
|
if (inHTMLBareString)
|
|
|
|
{
|
|
|
|
NSDebugMLLog0(@"low",@"==>Stop BareString");
|
|
|
|
stopBareString=YES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
ANTLRDefAST nextAST=[currentAST nextSibling];
|
2000-10-04 22:19:43 +00:00
|
|
|
NSString* name=[tagAttrs objectForKey:@"name"];
|
|
|
|
NSDebugMLLog0(@"low",@"Process GSWeb Tag");
|
|
|
|
NSDebugMLLog(@"low",@"GSWeb Tag: name:[%@]",
|
|
|
|
name);
|
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
LOGError(@"No name for Element:%@",
|
2002-08-04 18:00:11 +00:00
|
|
|
[currentAST text]);//TODO
|
2000-10-04 22:19:43 +00:00
|
|
|
ExceptionRaise(@"GSWTemplateParser",
|
|
|
|
@"GSWTemlateParser: no name for GNUstepWeb tag in template named %@",
|
|
|
|
_templateName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GSWPageDefElement* pageDefElement=[_definitions objectForKey:name];
|
|
|
|
NSDebugMLLog(@"low",@"pageDefElement:[%@]",
|
|
|
|
pageDefElement);
|
|
|
|
NSDebugMLLog(@"low",@"GSWeb Tag pageDefElement:[%@]",
|
|
|
|
pageDefElement);
|
|
|
|
if (pageDefElement)
|
|
|
|
{
|
|
|
|
NSDictionary* _associations=[pageDefElement associations];
|
|
|
|
NSString* className=nil;
|
|
|
|
className=[pageDefElement className];
|
|
|
|
NSDebugMLLog(@"low",@"GSWeb Tag className:[%@]",
|
|
|
|
className);
|
|
|
|
if (className)
|
|
|
|
{
|
|
|
|
NSArray* children=nil;
|
|
|
|
children=[self createElementsStartingWithAST:&nextAST
|
|
|
|
stopOnTagNamed:tagName];
|
|
|
|
NSDebugMLLog(@"low",@"CREATE Element of Class:%@",className);
|
|
|
|
NSDebugMLLog(@"low",@"children:%@",children);
|
|
|
|
NSDebugMLLog(@"low",@"associations:%@",_associations);
|
|
|
|
{
|
|
|
|
NSEnumerator* _tagAttrsEnum = [tagAttrs keyEnumerator];
|
|
|
|
id _tagAttrKey=nil;
|
|
|
|
id _tagAttrValue=nil;
|
|
|
|
NSMutableDictionary* _addedAssoc=nil;
|
|
|
|
while ((_tagAttrKey = [_tagAttrsEnum nextObject]))
|
|
|
|
{
|
|
|
|
if (![_tagAttrKey isEqualToString:@"name"]
|
|
|
|
&& ![_associations objectForKey:_tagAttrKey])
|
|
|
|
{
|
|
|
|
if (!_addedAssoc)
|
|
|
|
_addedAssoc=[NSMutableDictionary dictionary];
|
|
|
|
_tagAttrValue=[tagAttrs objectForKey:_tagAttrKey];
|
|
|
|
[_addedAssoc setObject:[GSWAssociation associationWithValue:_tagAttrValue]
|
|
|
|
forKey:_tagAttrKey];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (_addedAssoc)
|
|
|
|
{
|
|
|
|
_associations=[_associations dictionaryByAddingEntriesFromDictionary:_addedAssoc];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
element=[GSWApp dynamicElementWithName:className
|
|
|
|
associations:_associations
|
|
|
|
template:[[[GSWHTMLStaticGroup alloc]initWithContentElements:children]autorelease]
|
|
|
|
languages:_languages];
|
2002-01-26 10:43:23 +00:00
|
|
|
if (element)
|
|
|
|
[element setDefinitionName:[pageDefElement elementName]];
|
|
|
|
else
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
ExceptionRaise(@"GSWTemplateParser",
|
|
|
|
@"GSWTemplateParser: Creation failed for element named:%@ className:%@ in template named %@",
|
|
|
|
[pageDefElement elementName],
|
|
|
|
className,
|
|
|
|
_templateName);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ExceptionRaise(@"GSWTemplateParser",
|
|
|
|
@"GSWTemplateParser: No class name in page definition for tag named:%@ pageDefElement=%@ in template named %@",
|
|
|
|
name,
|
|
|
|
pageDefElement,
|
|
|
|
_templateName);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ExceptionRaise(@"GSWTemplateParser",
|
|
|
|
@"No element definition for tag named:%@ in template named %@",
|
|
|
|
name,
|
|
|
|
_templateName);
|
|
|
|
};
|
|
|
|
};
|
2002-08-04 18:00:11 +00:00
|
|
|
currentAST=nextAST;
|
2000-10-04 22:19:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
if (stopTagName
|
|
|
|
&& [tagName caseInsensitiveCompare:stopTagName]==NSOrderedSame)
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"stopTagName found: %@",stopTagName);
|
2000-10-04 22:19:43 +00:00
|
|
|
end=YES;
|
|
|
|
stopBareString=YES;
|
2002-08-04 18:00:11 +00:00
|
|
|
currentAST=[currentAST nextSibling];
|
2000-10-04 22:19:43 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2002-08-04 18:00:11 +00:00
|
|
|
else if ([currentAST tokenType]==GSWHTMLTokenType_COMMENT)
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
stopBareString=YES;
|
2002-08-04 18:00:11 +00:00
|
|
|
element=[GSWHTMLComment elementWithString:[currentAST text]];
|
|
|
|
currentAST=[currentAST nextSibling];
|
2000-10-04 22:19:43 +00:00
|
|
|
}
|
|
|
|
NSDebugMLLog(@"low",@"end=%s inHTMLBareString=%s stopBareString=%s",
|
|
|
|
end ? "YES" : "NO",
|
|
|
|
inHTMLBareString ? "YES" : "NO",
|
|
|
|
stopBareString ? "YES" : "NO");
|
|
|
|
if (!element && !end && !stopBareString)
|
|
|
|
{
|
|
|
|
NSDebugMLLog0(@"low",@"!element && !end && !stopBareString");
|
|
|
|
if (!inHTMLBareString)
|
|
|
|
{
|
|
|
|
NSDebugMLLog0(@"low",@"!inHTMLBareString ==> inHTMLBareString=YES");
|
|
|
|
inHTMLBareString=YES;
|
|
|
|
htmlBareString=[[NSMutableString new] autorelease];
|
|
|
|
};
|
2002-08-04 18:00:11 +00:00
|
|
|
NSDebugMLLog(@"low",@"inHTMLBareString: adding [%@]",[currentAST text]);
|
|
|
|
if ([currentAST tokenType]==GSWHTMLTokenType_OPENTAG)
|
|
|
|
[htmlBareString appendFormat:@"<%@>",[currentAST text]];
|
|
|
|
else if ([currentAST tokenType]==GSWHTMLTokenType_CLOSETAG)
|
|
|
|
[htmlBareString appendFormat:@"</%@>",[currentAST text]];
|
2000-10-04 22:19:43 +00:00
|
|
|
else
|
2002-08-04 18:00:11 +00:00
|
|
|
[htmlBareString appendString:[currentAST text]];
|
2000-10-04 22:19:43 +00:00
|
|
|
NSDebugMLLog(@"low",@"htmlBareString: ==> [%@]",htmlBareString);
|
2002-08-04 18:00:11 +00:00
|
|
|
currentAST=[currentAST nextSibling];
|
2000-10-04 22:19:43 +00:00
|
|
|
};
|
2002-08-04 18:00:11 +00:00
|
|
|
if (inHTMLBareString && (stopBareString || !currentAST))
|
2000-10-04 22:19:43 +00:00
|
|
|
{
|
|
|
|
NSDebugMLLog0(@"low",@"inHTMLBareString && stopBareString");
|
|
|
|
NSDebugMLLog(@"low",@"CREATE GSWHTMLBareString:\n%@",htmlBareString);
|
|
|
|
element=[GSWHTMLBareString elementWithString:htmlBareString];
|
|
|
|
NSDebugMLLog(@"low",@"element:%@",element);
|
|
|
|
htmlBareString=nil;
|
|
|
|
inHTMLBareString=NO;
|
|
|
|
};
|
|
|
|
if (element)
|
|
|
|
{
|
|
|
|
NSDebugMLLog(@"low",@"element to add: element=[%@]",element);
|
2002-08-04 18:00:11 +00:00
|
|
|
[elements addObject:element];
|
2000-10-04 22:19:43 +00:00
|
|
|
element=nil;
|
|
|
|
};
|
|
|
|
NSDebugMLLog(@"low",@"element:%@",element);
|
|
|
|
NSDebugMLLog(@"low",@"inHTMLBareString:%d",(int)inHTMLBareString);
|
|
|
|
NSDebugMLLog(@"low",@"htmlBareString:%@",htmlBareString);
|
|
|
|
};
|
2002-08-04 18:00:11 +00:00
|
|
|
*anAST=currentAST;
|
|
|
|
NSDebugMLLog(@"low",@"elements]:%@",elements);
|
2000-10-04 22:19:43 +00:00
|
|
|
LOGClassFnStop();
|
2002-08-04 18:00:11 +00:00
|
|
|
return elements;
|
2000-10-04 22:19:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@end
|
|
|
|
|