...
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Generating the XML schema
You can use the database connector to generate the schemas you will need to use in your form. To fetch the schema, type a URI in the browser that looks like the example below. This is almost identical to the query we used to test the connector, but it tells the connector to GET the schema instead.
Code Block | ||
---|---|---|
| ||
http://<host>:<port>/database/<queryset name>/<query name>/schema?<template name>=<template value> |
If your SQL Retrieve statement includes template variables, you’ll need to add the variable names as shown below. The schema itself does not require variables but the connector fetches the schema the same way it fetches data for the retrieve statement, so the connector expects the template names and values in the URI.
For the example we've been using so far, point your browser to the url: http://localhost:8082/database/BIRT/allCustomers/schema?customerNumber=237
You should get an XML schema similar to the following:
Code Block |
---|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema xmlns="http://www.frevvo.com/database/allCustomers" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.frevvo.com/database/allCustomers">
<xsd:annotation>
<xsd:appinfo xmlns:f="http://www.frevvo.com/database/" f:connectorVersion="2.5.3-r30969" f:digest="4f2c46033e8ff5a221ab7106c4003833157e7f6a" f:last-modified="Sat Aug 19 19:06:45 EDT 2017" source="http://www.frevvo.com/database/"/>
</xsd:annotation>
<xsd:element name="allCustomers">
<xsd:annotation>
<xsd:appinfo xmlns:f="http://www.frevvo.com/database/" f:autoCreate="true" f:autoDelete="false" f:enabled="true" source="http://www.frevvo.com/database/"/>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="row">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="customerNumber" type="xsd:int"/>
<xsd:element name="customerName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
|
Note |
---|
The f:connectorVersion="2.5.3-r30969 attribute in the above example reports the version of the Database Connector that was used to generate the schema. The f:last-modified="Sat Aug 19 19:06:45 EDT 2017 attribute reports the date/time of the last modification to your configuration.xml file. These attributes will help you manage xsd changes. |
Save the schema as an .xsd file in your file system.
Note |
---|
Your schema may not work correctly if you generated the schema in the Chrome browser and then used the Select All, copy/paste function to create the xsd file. Use the Save Page As function instead. |
You can then upload the schema to and generate controls from the schema elements that map to your database tables. If you have multiple queries in your configuration file, you have two options:
Generate the schemas for an entire queryset. When there are a large number of queries in the configuration.xml, getting the schemas for all of them eliminates having to create a schema one by one for each query. The queryset schema can be uploaded to your project one time and then you can add the relevant schema elements to your forms/workflows as you need them.
Code Block http://<server>:<port>/database/BIRT/schema
Generate a schema for each query.
Code Block http://<server>:<port>/database/BIRT/allCustomers/schema
Tip |
---|
The word "schema" is a reserved word for query names. If you have a query in your configuration.xml with a name that includes the word "schema" will show an error. |
Using Your Schema
Before you can use global elements from a schema in a form, you must upload the schema XSD file into one of your projects. To upload a schema:
...