xmlToStruct in memory?

Author: i2stiller@gmx.de (istiller)

xmlToStruct

Is it possible to locate the XSD for xmlToStruct in memory?

Background: We do a full validation of a XML-stream with different given XSD files. First I extract the namespace out of the XML. Then I do a lookup in database for the XSD and dump this to disk. Now I can use xmlToStruct to validate the XML against this XSD-file

But, as we are now using concurrent processes,  this dumping and using of external XSD is the source of an error Two USERVER-processes can not obtain the XSD at the same time (looks like this).

A workaround could be a postfix to the XSD filename, containing the process ID.

Best practice would be to have the XSD in memory of each process, but how to do this?

Regards Ingo

 

 

3 Comments

  1. Sh.., workaround doesn't work. As we are using two XSD files, one imported into the other one by  <import .../>, I have two rename two files. And there I do have a problem. It seems to me, that UnifAce could not handle import without a schemalocation. Before I did change the XSD, the XSD looks like this

    - A.XSD-
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema elementFormDefault="qualified"
        targetNamespace="A"
        xmlns:A="A"
        xmlns:B="B"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:import namespace="B" schemaLocation="B.xsd" />
    
    - B.XSD -
    ...
    
    After the set a postfix

    Before I did change the XSD, the XSD looks like this

    - A_4711.XSD-
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema elementFormDefault="qualified"
        targetNamespace="A"
        xmlns:A="A"
        xmlns:B="B"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:import namespace="B" schemaLocation="B.xsd" />
    
    - B_4711.XSD -
    ...

    Okay, A_4711.XSD will never find the B_4711.XSD. And as the name of B_xyz.XSD is not fix, I could not set "right" name So, I remove the schemaLocation for import (it's optional)

    - A_4711.XSD-
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema elementFormDefault="qualified"
        targetNamespace="A"
        xmlns:A="A"
        xmlns:B="B"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:import namespace="B"  />
    
    - B_4711.XSD -
    ...
    Via the UIL "schemalist" as last parameter of xmlToStruc I do provided both namespace.

      But I got an error -1504 "Schema Representation Constraint: Namespace 'B' is referenced without <import> declaration'" Sorry, there is an import ! I did check this XSD  against other  tools,  and it looks quiet okay. So what is wrong? Or are there other workaround?


    Author: istiller (i2stiller@gmx.de)
  2. istiller said xmlToStruct

    Is it possible to locate the XSD for xmlToStruct in memory? 

    Hi Ingo, The short answer is: No, at this moment you can refer to a single schema (only) by a file name or an URL (as documented in the Uniface Library). A possible workaround could be to embed the schema definitions (XSD) into the XML (instead of importing the XSD). In this case the XSD actually would be located in memory. Hope this helps. Regards, Daniel


    Author: diseli (daniel.iseli@uniface.com)
  3. istiller said Sh.., workaround doesn't work. As we are using two XSD files, one imported into the other one by  , I have two rename two files. And there I do have a problem. It seems to me, that UnifAce could not handle import without a schemalocation. Before I did change the XSD, the XSD looks like this
    - A.XSD-
    
    
        targetNamespace="A"
        xmlns:A="A"
        xmlns:B="B"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        
    - B.XSD -
    ...
    After the set a postfix
    Before I did change the XSD, the XSD looks like this
    - A_4711.XSD-
    
    
        targetNamespace="A"
        xmlns:A="A"
        xmlns:B="B"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        
    - B_4711.XSD -
    ...
    Okay, A_4711.XSD will never find the B_4711.XSD. And as the name of B_xyz.XSD is not fix, I could not set "right" name So, I remove the schemaLocation for import (it's optional)
    - A_4711.XSD-
    
    
        targetNamespace="A"
        xmlns:A="A"
        xmlns:B="B"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
        
    - B_4711.XSD -
    ...
    Via the UIL "schemalist" as last parameter of xmlToStruc I do provided both namespace.
      But I got an error -1504 "Schema Representation Constraint: Namespace 'B' is referenced without declaration'" Sorry, there is an import ! I did check this XSD  against other  tools,  and it looks quiet okay. So what is wrong? Or are there other workaround?  

    Not sure what's wrong here. Did you also check $procReturnContext if it contains any additional warning or errors? Anyways, I did a quick test here and xmlToStruct/validate seems to work fine when I do the stuff you describe. Here are a couple of things I've recognized:

    1. You actually can leave the schemaList parameter empty if all the imports are correctly specified in the XML and XSD files and the referenced files can be loaded.
    2. You only need to specify the Namespace/Location name-value pairs list in schemaList if the import is pointing to an unavailable XSD location

    Maybe you could provide a complete sample I could look at (i.e. test form, XML and XSD files). Hope this helps. Regards, Daniel


    Author: diseli (daniel.iseli@uniface.com)