diff --git a/wst/trunk/ws_helper/xsd_parser.pas b/wst/trunk/ws_helper/xsd_parser.pas index 2a506f009..2e105eb7a 100644 --- a/wst/trunk/ws_helper/xsd_parser.pas +++ b/wst/trunk/ws_helper/xsd_parser.pas @@ -168,7 +168,7 @@ type end; implementation -uses ws_parser_imp, dom_cursors, parserutils, xsd_consts +uses ws_parser_imp, dom_cursors, parserutils, xsd_consts, wst_consts {$IFDEF FPC} ,wst_fpc_xml {$ENDIF} @@ -192,13 +192,11 @@ constructor TCustomXsdSchemaParser.Create( ); begin if ( ADoc = nil ) then - raise EXsdParserAssertException.Create('Invalid DOM document.'); + raise EXsdParserAssertException.Create(SERR_InvalidDomDocument); if ( ASchemaNode = nil ) then - raise EXsdParserAssertException.Create('Invalid schema node.'); + raise EXsdParserAssertException.Create(SERR_InvalidSchemaNode); if ( ASymbols = nil ) then - raise EXsdParserAssertException.Create('Invalid Symbol table.'); - if ( ASchemaNode = nil ) then - raise EXsdParserAssertException.Create('Invalid schema node.'); + raise EXsdParserAssertException.Create(SERR_InvalidSymbolTable); FDoc := ADoc; FParentContext := Pointer(AParentContext); @@ -493,7 +491,7 @@ var else typNd := FindNamedNode(crsSchemaChild,localTypeName); if not Assigned(typNd) then - raise EXsdTypeNotFoundException.CreateFmt('Type definition not found 1 : "%s"',[AName]); + raise EXsdTypeNotFoundException.CreateFmt(SERR_TypeDefinitionNotFound,['1',AName]); if AnsiSameText(ExtractNameFromQName(typNd.NodeName),s_element) then begin crs := CreateCursorOn(CreateAttributesCursor(typNd,cetRttiNode),ParseFilter(Format('%s = %s',[s_NODE_NAME,QuotedStr(s_type)]),TDOMNodeRttiExposer)); crs.Reset(); @@ -514,12 +512,12 @@ var oldTypeNode := typNd; typNd := FindNamedNode(crsSchemaChild,ExtractNameFromQName(nd.NodeValue)); if not Assigned(typNd) then - raise EXsdTypeNotFoundException.CreateFmt('Type definition not found 2 : "%s"',[AName]); + raise EXsdTypeNotFoundException.CreateFmt(SERR_TypeDefinitionNotFound,['2',AName]); embededType := False; if ( typNd = oldTypeNode ) then begin typNd := FindNamedNode(crsSchemaChild,ExtractNameFromQName(nd.NodeValue),2); if not Assigned(typNd) then - raise EXsdTypeNotFoundException.CreateFmt('Type definition not found 2.1 : "%s"',[AName]); + raise EXsdTypeNotFoundException.CreateFmt(SERR_TypeDefinitionNotFound,['2.1',AName]); end; end; end else begin @@ -529,7 +527,7 @@ var crs := CreateCursorOn(CreateChildrenCursor(typNd,cetRttiNode),ParseFilter(locStrFilter,TDOMNodeRttiExposer)); crs.Reset(); if not crs.MoveNext() then begin - raise EXsdTypeNotFoundException.CreateFmt('Type definition not found 3 : "%s"',[AName]); + raise EXsdTypeNotFoundException.CreateFmt(SERR_TypeDefinitionNotFound,['3',AName]); end; typNd := (crs.GetCurrent() as TDOMNodeRttiExposer).InnerObject; typName := ExtractNameFromQName(AName); @@ -604,7 +602,7 @@ begin if not FImportParsed then ParseImportDocuments(); sct := nil; - DoOnMessage(mtInfo, Format('Parsing "%s" ...',[AName])); + DoOnMessage(mtInfo, Format(SERR_Parsing,[AName])); try embededType := False; aliasType := nil; @@ -613,7 +611,7 @@ begin typeModule := FModule; end else begin if not FindNameSpace(shortNameSpace,longNameSpace) then - raise EXsdParserAssertException.CreateFmt('Unable to resolve namespace, short name = "%s".',[shortNameSpace]); + raise EXsdParserAssertException.CreateFmt(SERR_UnableToResolveNamespace,[shortNameSpace]); typeModule := SymbolTable.FindModule(longNameSpace); end; if ( typeModule = nil ) then @@ -648,7 +646,7 @@ begin SymbolTable.RegisterExternalAlias(Result,SymbolTable.GetExternalName(frwType)); end; end else begin - raise EXsdTypeNotFoundException.CreateFmt('Type node found but unable to parse it : "%s"',[AName]); + raise EXsdTypeNotFoundException.CreateFmt(SERR_TypeNodeFoundButUnableToParseIt,[AName]); end; end else begin Result := CreateTypeAlias(aliasType); @@ -777,10 +775,10 @@ var ls : TStrings; begin if ( FSchemaNode.Attributes = nil ) or ( GetNodeListCount(FSchemaNode.Attributes) = 0 ) then - raise EXsdParserAssertException.CreateFmt('The Schema node must have at least the "%s" attribute.',[s_targetNamespace]); + raise EXsdParserAssertException.CreateFmt(SERR_SchemaNodeRequiredAttribute,[s_targetNamespace]); nd := FSchemaNode.Attributes.GetNamedItem(s_targetNamespace); if ( nd = nil ) then - raise EXsdParserAssertException.CreateFmt('The Schema node must have at least the "%s" attribute.',[s_targetNamespace]); + raise EXsdParserAssertException.CreateFmt(SERR_SchemaNodeRequiredAttribute,[s_targetNamespace]); FTargetNameSpace := nd.NodeValue; if IsStrEmpty(FModuleName) then FModuleName := ExtractIdentifier(FTargetNameSpace); @@ -795,10 +793,10 @@ begin prntCtx := GetParentContext(); if ( FXSShortNames = nil ) then begin if ( prntCtx = nil ) then - raise EXsdParserAssertException.CreateFmt('Invalid Schema document, namespace not found :'#13'%s.',[s_xs]); + raise EXsdParserAssertException.CreateFmt(SERR_InvalidSchemaDoc_NamespaceNotFound,[s_xs]); FXSShortNames := prntCtx.FindShortNamesForNameSpace(s_xs); if ( FXSShortNames = nil ) then - raise EXsdParserAssertException.CreateFmt('Invalid Schema document, namespace not found ( short names ) :'#13'%s.',[s_xs]); + raise EXsdParserAssertException.CreateFmt(SERR_InvalidSchemaDoc_NamespaceNotFoundShort,[s_xs]); end; if Assigned(prntCtx) then begin diff --git a/wst/trunk/wst_consts.pas b/wst/trunk/wst_consts.pas index 0ae58046c..95fe04204 100644 --- a/wst/trunk/wst_consts.pas +++ b/wst/trunk/wst_consts.pas @@ -46,6 +46,7 @@ resourcestring SERR_InvalidCollectionLength = 'Invalid collection length : %d.'; SERR_InvalidComplexSimpleTypeDef_NoRestOrExt = 'Invalid "complexeType.simpleType" definition : restriction/extension not found.'; SERR_InvalidDataTypeInContext = 'Invalid data type in this context : "%s".'; + SERR_InvalidDomDocument = 'Invalid DOM document.'; SERR_InvalidElementDef_MissingNameOrRef = 'Invalid definition : missing "name" or "ref" attribute.'; SERR_InvalidElementDef_EmptyName = 'Invalid definition : empty "name".'; SERR_InvalidElementDef_EmptyType = 'Invalid definition : empty "type".'; @@ -62,6 +63,10 @@ resourcestring SERR_InvalidParameterProc = 'Invalid parameter : "%s"; Procedure = "%s".'; SERR_InvalidParameters = 'Invalid parameters.'; SERR_InvalidPoolParametersArgs = 'Invalid pool arguments Min = %d; Max = %d .'; + SERR_InvalidSchemaDoc_NamespaceNotFound = 'Invalid Schema document, namespace not found : %s.'; + SERR_InvalidSchemaDoc_NamespaceNotFoundShort = 'Invalid Schema document, namespace not found ( short names ) : %s.'; + SERR_InvalidSchemaNode = 'Invalid schema node.'; + SERR_InvalidSymbolTable = 'Invalid Symbol table.'; SERR_InvalidTypeDef_AttributeNotFound = 'Invalid type definition, attributes not found : "%s".'; SERR_InvalidTypeDef_BaseAttributeNotFound = 'Invalid extention/restriction of type "%s" : "base" attribute not found.'; SERR_InvalidTypeDef_NamedAttributeNotFound = 'Invalid type definition, unable to find the "%s" attribute : "%s".'; @@ -76,14 +81,19 @@ resourcestring SERRE_ObjectCreationTimeOut = 'Unable to create the object : Timeout expired.'; SERR_OperationNotAllowedOnActivePool = 'Operation not allowed on an active pool.'; SERR_ParamaterNotFound = 'Parameter non found : "%s".'; + SERR_Parsing = 'Parsing "%s" ...'; SERR_RecordExtendedRttiNotFound = 'Record extended RTTI informations not found in type registry : "%s".'; SERR_RootObjectCannotBeNIL = 'The root object cannot be NIL.'; + SERR_SchemaNodeRequiredAttribute = 'The Schema node must have at least the "%s" attribute.'; SERR_SerializerInitializationException = 'Unable to initialize the serializer of that type : "%s".'; SERR_ServiceNotFound = 'Service not found : "%s".'; SERR_ScopeNotFound = 'Scope not found : "%s".'; + SERR_TypeDefinitionNotFound = 'Type definition not found %s : "%s"'; + SERR_TypeNodeFoundButUnableToParseIt = 'Type node found but unable to parse it : "%s"'; SERR_TypeNotRegistered = 'Type not registered : "%s".'; SERR_TypeStyleNotSupported = 'This type style is not supported : "%s".'; SERR_UnableToFindNameTagInNode = 'Unable to find the tag in the type/element node attributes.'; + SERR_UnableToResolveNamespace = 'Unable to resolve namespace, short name = "%s".'; SERR_UnexpectedEndOfData = 'Unexpected end of data.'; SERR_UnknownProperty = 'Unknown property : "%s".'; SERR_UnsupportedOperation = 'Unsupported operation : "%s".';