Hi Tim,

unsurprisingly, I would now recommend ADS/JavaScript. I am attaching an example to get you started. Put it into your EDG Studio workspace, edit the file and open its Swagger UI on the Reports tab:

The (minimal) code for this output is:

To generate XSD from an ontology, the idea would be that you traverse all classes (owl.everyClass()) - here I did sh.everyNodeShape() and then recursively write functions that process it class by class, e.g. to create XSD field declarations for all datatype properties etc.

This starting point may give you some ideas. The alternative would be to use SWP in a similar manner, but it the code would be much harder to maintain and you don't have as much flexibility as a full programming language like JavaScript.

Regards,
Holger



On 2022-05-06 4:58 am, Tim Smith wrote:
Hi,

I have a need to express an ontology as specified by an XML schema.  This schema is defined by a vendor to represent a class model in their proprietary schema.

Many years ago, I used SWP and the ui:instance view property to assemble HTML pages to drive a wiki straight from the old TopBraid Live product.  I was able to define how each instance should render itself at the class level.  I think the same thing will work here where I define how Node Shapes and Property Shapes should represent themselves in this proprietary XML schema.

Given all the changes to TBC/EDG since I last did this (2011???), what is the current best approach to expressing an RDF/OWL/SHACL structure as an XML schema?  SWP? ADS/Javascript?

Thanks in advance for your input,

Tim
--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/CAF0WbnLnGCZM3KT764iDQTB56WPpUJ8JX_wiu9%3DM6xjkETjphg%40mail.gmail.com <https://groups.google.com/d/msgid/topbraid-users/CAF0WbnLnGCZM3KT764iDQTB56WPpUJ8JX_wiu9%3DM6xjkETjphg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "TopBraid 
Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/topbraid-users/dc4f5b51-783a-2715-2d61-ced2d0e5d0b0%40topquadrant.com.
# baseURI: http://example.org/generatexml
# imports: http://datashapes.org/dash
# prefix: ex

@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://example.org/generatexml#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/generatexml>
  a owl:Ontology ;
  <http://topbraid.org/swa#defaultNamespace> "http://example.org/generatexml#"; ;
  rdfs:label "New File (generatexml.ttl)" ;
  owl:imports <http://datashapes.org/dash> ;
.
ex:GenerateXML
  a dash:GraphService ;
  dash:apiStatus dash:Experimental ;
  dash:js """`<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
        ${sh.everyNodeShape().map(renderNodeShape).join('\\n')}
</xs:schema>
`

/**
 * Produces the XML for a given NodeShape.
 * @param {sh_NodeShape} nodeShape
 */
function renderNodeShape(nodeShape) {
        return `<xs:element name="${graph.qname(nodeShape.uri)}">
                        <xs:complexType>
                        </xs:complexType>
                </xs:element>`;
}""" ;
  dash:responseContentType "application/xml" ;
  rdfs:label "Generate XML" ;
.

Reply via email to