Validate format and content of XSD file - validation

I searched under and over for this, but I think I am not using the correct words for my query.
I need to validate the format and content of an XML Schema (xsd) file. I also need to do this by command line. To give more guidance, I would like something like the Eclipse schema editor as an example (but by command line).
Let's say I have this schema:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/ExampleXMLSchema"
xmlns:tns="http://www.example.org/ExampleXMLSchema"
xmlns:external="http://www.example.org/ExternalXMLSchema"
elementFormDefault="unqualified">
<import schemaLocation="ExternalXMLSchema.xsd"
namespace="http://www.example.org/ExternalXMLSchema">
</import>
<complexType name="ExampleComplexType">
<sequence>
<element name="ExternalElement"
type="external:ExternalComplexType"></element>
</sequence>
</complexType>
</schema>
I want a tool that validate the format (no missing brackets, no missing end tags, etc), but also make sure that external references are correct. In this example, it would fail if the validator could not find the ExternalXMLSchema.xsd file and its types.
The eclipse editor gives this error for this situation:
src-resolve: Cannot resolve the name 'external:ExternalComplexType' to a(n) 'type definition' component.
Thanks for taking a look at this! Sorry if something is not clear, first post here, trying my best.

Any schema validator will have the schema for schema documents built in, so any schema validator should be in a position to validate a schema document.
Checking for bad external references goes beyond checking the schema-validity of the schema document; with some validators I have used, the validator checks external references if you ask it to validate a schema document; with others, it doesn't.
So in general the most reliable way of getting a validator to check a schema document is to attempt to use it to validate an XML instance. I find it convenient to have an instance with a well understood validity error. If the validator issues an error message concerning that problem in the XML instance, the schema is OK; if the validator issues no error messages at all, it's not building the schema or something else is wrong. If it issues a list of complaints about problems in the schema, well, that's what you were looking for, wasn't it?
Among schema validators which can be invoked from the command line are Xerces-J, Xerces-C, Saxon, msv, and libxml (but n.b. libxml's support for XSD is incomplete).

Related

spring properties - structure

I've got a scenario where I have the following type of data that I want to specify in my properties file.
To describe it I have a domain, each which can have a type and subtype.
wallet.items.domain=APPLE,DOMAIN_TWO
wallet.domain.types.apple=TYPE_ONE, PAYPAL
wallet.domain.subtypes.apple=SUB_TYPE_ONE
wallet.domain.types.paypal=TYPE_ONE, TYPE_TWO, TYPE_THREE
wallet.domain.subtypes.paypal=SUB_TYPE_ONE, SUB_TYPE_TWO, SUB_TYPE_THREE, SUB_TYPE_FOUR
I want to validate that the types and the subtypes for a domain are valid in a generic manner. For example these are valid combinations.
APPLE, TYPE_ONE, SUB_TYPE_ONE
APPLE, TYPE_TWO, SUB_TYPE_ONE
APPLE, TYPE_TWO, SUB_TYPE_ONE
PAYPAL,TYPE_ONE,SUB_TYPE_ONE
My first challenge is to structure this in a properties file such that I can use them in a validate routine in groovy generically.
I'm using spring for property file mnmgt.
Can anyone help me with a nice generic way to do this?

Mapping existing resource to hl7-fhir response

Trying to understand the concept of the code datatype in hl7-fhir. Looking at the appointment (https://www.hl7.org/fhir/appointment.html) resource as an example it has a status parameter with suggested values of "proposed | pending | booked" etc.
Given an existing database with it's own custom status' (Attended, Confirmed, Attended but late) what is the correct way to handle a hl7-fhir response to a consumer?
If the "code" data type is used, then the FHIR binding strength is always "required" - which means you are required to use the FHIR-defined list of codes and no others.
It appears that two of your statuses - "Attended" and "Attended but late" aren't actually statuses of the appointment - the booking, but are instead commentary about the resulting encounter. So I would capture those as extensions. "confirmed" sounds similar to "booked", though I'd need to know the definition to know for sure. Do you have any appointment statuses for appointments that are not yet confirmed (let alone attended)?
To extend on Lloyds notes, you will want to put the extension under the status property, and map your existing values to the provided FHIR values, and put your local actual value in the extension underneath.
This way when other systems read the resource and don't know about your extension status values, they will still be able to act sensibly based on the core values.
<status value="fulfilled">
<extension url="http://yourorg.com/fhir/.../ExtendedAppointmentStatuses">
<valueCoding>
<code value="abl" />
<display value="Attended but late" />
</valueCoding>
</extension>
</status>

Validate against schema fragment

I'm new to json-schema so it might not be a relevant issue.
I'm using https://github.com/hoxworth/json-schema.
I have one big json file describing a lot of schemas (mostly small ones) with a lot $ref between schemas, and I need to be able to validate data against one of these "inner" schemas. I can't find a way to do this with json-schema.
Does json-schema support this use case, or am I doing it wrong ?
It appears it does. It states that it uses the json schema v4. Also in the source code: line 265 lib/json-schema/validator.rb.
def build_schemas(parent_schema)
# Build ref schemas if they exist
if parent_schema.schema["$ref"]
load_ref_schema(parent_schema, parent_schema.schema["$ref"])
end

How to detect "for internal use only" entities from Dynamics CRM metadata

I am trying to read (FetchXml) the content of all the readable attributes of all the entities based on the list I get using the metadata webservice.
This works fine except for 3 entities ("resourcegroupexpansion", "workflowwaitsubscription" and "interprocesslock") for which I systematically get the following error:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request.</faultstring>
<detail>
<error>
<code>0x80040216</code>
<description>An unexpected error occurred.</description>
<type>Platform</type>
</error>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
According to this http://msdn.microsoft.com/en-us/library/gg328086.aspx those 3 entities are for internal use only which might explain why I get an error (having said that I’m able to read other “internal use only” entities).
So my question is this: how can I detect from the metadata which entities are “for internal use only” and which are not ?
Of course, I could hard-code the list of entities based on the documentation but I don’t find it very satisfying.
Unfortunately there is No flag to identify the "for Internal use only" entities.
But one thing I noticed from XrmToolbox Metadata browser - the description column of entity is having "for Internal use only" text for ~15 entities.
We can leverage the same by identifying & updating this field with unique values for internal system entities (thru some unsupported way like export solution, modify & reimport). Then description field text can be used to filter out these internal entities.
I never tried this. Will try & update my answer soon.

Add contents of Dexterity NamedBlobFile to SearchableText

I've created a dexterity content type that has a NamedBlobFile as one of the fields (users will upload a .pdf). I'd like to have full-text indexing on that pdf -- like the ATFile type -- but not sure what I have to do to make that happen.
I've installed collective.dexteritytextindexer and have gotten some of the other fields added to searchable text by doing this:
searchable('paper_author')
paper_author = schema.Text(title=_(u"Author"), required=False)
I'm not sure what to do for the file field. Suggestions?
I think using the searchable() directive should work for NameBlobFiles too.
There is a converter in collective.dexteritytextindexer taking care of transforming the file contents into text so that it is indexable (see the code at github), which also applies for blobs (since the INamedBlobFileField subclasses INamedFileField for which the adapter is registered).
If it does not work its a bug, so please create an issue at the collective.dexteritytextindexer issue tracker.
If the problem is that the field is not defined in your code and you cannot use the searchable directive, there is also a searchable function (import from .utils!) which can be used outside the scope of the schema like this:
from plone.app.dexterity.behaviors.metadata import IBasic
from collective.dexteritytextindexer.utils import searchable
searchable(IBasic, 'title')
searchable(IBasic, 'description')

Resources