Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Internet/XML/Data Binding    [ Add a report in this area ]  
Report #:  8656   Status: Closed
XML Schema parser doesn't handle the schema files from OAGIS.
Project:  Delphi Build #:  8.1
Version:    9.0 Submitted By:   Mark Edington (Embarcadero)
Report Type:  Basic functionality failure Date Reported:  7/16/2004 11:11:09 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   204492
Resolution: Fixed (Resolution Comments) Resolved in Build: : 9.0.1761.24408
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: None
Description
When attempting to parse the set of schema files that comprise the OAGIS 8.0 (Open Application Group - files from http://www.openapplications.org/downloads/oagidownloads.htm), the XML Schema parser fails.  It does not handle the relative paths used in the files correctly, and it also fails to resolve type references from included schemas.
Steps to Reproduce:
Extract the attached OAGIS.zip files using paths.
Open the XMLSchemaDemo application.
Run it and click the button.
Select the BOD\AddPurchaseOrder.xsd file as the input.
Note the error messages which occur, the treeview should populate with the data from the schema files.
Workarounds
There are 2 code changes that must be made to the XMLSchema.pas source file in order to correctly parse these shemas.  Replace the following 2 methods in XMLSchema.pas and recompile the application using the modified source files:

function TXMLSchemaItems.FindItem(const Name: DOMString): IXMLSchemaItem;
var
  ItemNS: DOMString;
begin
  if IsPrefixed(Name) then
    ItemNS := SchemaDef.FindNamespaceURI(Name)
  else
    ItemNS := VarToStr(SchemaDef.TargetNamespace);
  Result := FindItemNS(Self, Name, ItemNS);
end;

function TXMLSchemaDef.LoadSchemaRef(SchemaLoc: DOMString): IXMLSchemaDef;
var
  I: Integer;
  FilePath, ImportPath: string;
begin
  if SchemaLoc <> '' then
  begin
    ImportPath := ExtractFilePath(SchemaLoc);
    FilePath := ExtractFilePath(OwnerDocument.FileName);
    if (FilePath <> '') and (ImportPath = '') then
      SchemaLoc := ExpandFileName(FilePath + SchemaLoc);
    Result := LoadXMLSchema(SchemaLoc).SchemaDef;
    for I := 0 to Length(FAppInfoClasses) - 1 do
      with FAppInfoClasses[I] do
        Result.RegisterAppInfo(NamespaceURI, Prefix, NodeClass);
  end;
end;

---------

There are 2 code changes that must be made to the XMLSchema.pas source file in order to correctly parse these shemas.  Replace the following 2 methods in XMLSchema.pas and recompile the application using the modified source files:

function TXMLSchemaItems.FindItem(const Name: DOMString): IXMLSchemaItem;
var
  ItemNS: DOMString;
begin
  if IsPrefixed(Name) then
    ItemNS := SchemaDef.FindNamespaceURI(Name)
  else
    ItemNS := VarToStr(SchemaDef.TargetNamespace);
  Result := FindItemNS(Self, Name, ItemNS);
end;

function TXMLSchemaDef.LoadSchemaRef(SchemaLoc: DOMString): IXMLSchemaDef;
var
  I: Integer;
  FilePath, ImportPath: string;
begin
  if SchemaLoc <> '' then
  begin
    ImportPath := ExtractFilePath(SchemaLoc);
    FilePath := ExtractFilePath(OwnerDocument.FileName);
    if (FilePath <> '') and (ImportPath = '') then
      SchemaLoc := ExpandFileName(FilePath + SchemaLoc);
    Result := LoadXMLSchema(SchemaLoc).SchemaDef;
    for I := 0 to Length(FAppInfoClasses) - 1 do
      with FAppInfoClasses[I] do
        Result.RegisterAppInfo(NamespaceURI, Prefix, NodeClass);
  end;
end;
Attachment
XMLSchemaDemo.zip
Comments

Mark Edington (Embarcadero) at 7/16/2004 11:48:18 AM -
Report submitted on behalf of Dave Brown who reported these issues on the borland.public.xml newsgroup.

Server Response from: ETNACODE01