OSI Selectors, what are their values? C++ - hex

I'm working with IEC61850 standard. And at first time I faced OSI Selectors: Transport selector, Session selector and Presentation selector. I'm not interested in their physical meaning.
The task is to convert their values from parsing file (from std::string) into uint8_t. I don't understand how are these values presented?
The values from file(xml schema):
<P type="OSI-PSEL">00000001</P>
<P type="OSI-SSEL">0001</P>
<P type="OSI-TSEL">0001</P>
or it can be
<P type="OSI-TSEL">00000001</P>
<P type="OSI-PSEL">01</P>
<P type="OSI-SSEL">01</P>
in xsd I got this infromation about them:
<xs:complexType name="tP_OSI-TSEL">
<xs:restriction base="tP">
<xs:maxLength value="8"/>
<xs:pattern value="[0-9,A-F]+"/>
</xs:restriction>
</xs:complexType>
<xs:complexType name="tP_OSI-SSEL">
<xs:restriction base="tP">
<xs:maxLength value="16"/>
<xs:pattern value="[0-9,A-F]+"/>
</xs:restriction>
</xs:complexType>
<xs:complexType name="tP_OSI-PSEL">
<xs:restriction base="tP">
<xs:maxLength value="16"/>
<xs:pattern value="[0-9,A-F]+"/>
</xs:restriction>
</xs:complexType>
Are 01 or 00001 or 00000001 etc represented in binary number system? Why do they have different length? I mean if 00000001 is an octet, what is 00001 and 01 then?

Related

Looping in DFDL

I am trying to convert a rally complex fixed length file into XML using DFDL and Daffodil. Each line will be responsible for one element and first element of each line will tell me what kind of element it will be. It can be Parent A or Parent B or it can be child AA or AB or BB or BA.
Where Parent A is one element ,Parent B is another and Child AA is first child of Element A.
Inside one file there are multiple Parent A and Parent B.
I tried initiator tag even tried choice tag but nothing seems to be working. Can anyone please help me out.
It's difficult to give a complete answer without example data, but using initiators and choices is likely the right approach. There are potentially simpler schemas depending on the specific data, but a generic solution might look something like this:
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/">
<xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format ref="GeneralFormat" lengthKind="delimited" />
</xs:appinfo>
</xs:annotation>
<xs:element name="File">
<xs:complexType>
<xs:sequence>
<xs:element name="Record" maxOccurs="unbounded">
<xs:complexType>
<xs:choice dfdl:initiatedContent="yes">
<xs:element name="ParentA" dfdl:initiator="ParentA:">
<xs:complexType>
<xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="postfix">
<xs:element name="Content" type="xs:string"/>
<xs:element name="Record" maxOccurs="unbounded">
<xs:complexType>
<xs:choice dfdl:initiatedContent="yes">
<xs:element name="ChildAA" type="xs:string" dfdl:initiator="ChildAA:" />
<xs:element name="ChildAB" type="xs:string" dfdl:initiator="ChildAB:" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ParentB" dfdl:initiator="ParentB:">
<xs:complexType>
<xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="postfix">
<xs:element name="Content" type="xs:string" />
<xs:element name="Record" maxOccurs="unbounded">
<xs:complexType>
<xs:choice dfdl:initiatedContent="yes">
<xs:element name="ChildBA" type="xs:string" dfdl:initiator="ChildBA:" />
<xs:element name="ChildBB" type="xs:string" dfdl:initiator="ChildBB:" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
This schema has the following features:
Each File has an unbounded number of Record's.
Each Record is a choice of either a ParentA or ParentB element, determined by the dfdl:initiator property.
Each Parent element contains the Content for that Parent (i.e. the stuff following the parent initiator) followed by an unbounded number of Child Records.
Each Child Record is also determined by the dfdl:initator property.
A postfix newline separator is used to determine when Parent Content and Child
content end.
This does not allow a ChildB elements to appear after a ParentA element and vice versa--child elements must always appear after the associated parent element. (If this restriction wasn't important, this schema could be greatly simplified).
The above allows data like this:
ParentA:Parent A Content
ChildAA:Child AA Content
ChildAB:Child AB Content
ParentB:Parent B Content
ChildBB:Child BB Content
ParentA:Parent A Content
ChildAB:Child AB Content
Which would parse into an XML infoset like this:
<File>
<Record>
<ParentA>
<Content>Parent A Content</Content>
<Record>
<ChildAA>Child AA Content</ChildAA>
</Record>
<Record>
<ChildAB>Child AB Content</ChildAB>
</Record>
</ParentA>
</Record>
<Record>
<ParentB>
<Content>Parent B Content</Content>
<Record>
<ChildBB>Child BB Content</ChildBB>
</Record>
</ParentB>
</Record>
<Record>
<ParentA>
<Content>Parent A Content</Content>
<Record>
<ChildAB>Child AB Content</ChildAB>
</Record>
</ParentA>
</Record>
</File>
The above is tested with Apache Daffodil 2.2.0

XSD 1.1 compare 2 dates

Related: XSD 1.1 compare 2 dates
Here's my XML schema snippet:
<xs:complexType name="headerType">
<xs:sequence>
<xs:element name="ContentDate" type="dateTime" />
<xs:element minOccurs="0" name="DeltaStart" type="lei:LEIDateTimeProfile" />
</xs:sequence>
<xs:assert test="empty(dateTime(./DeltaStart) gt dateTime(./ContentDate))" />
</xs:complexType>
<xs:element name="header" type="headerType" />
Any ideas why the following XML snippet is causing a validation error?
<header>
<ContentDate>2017-02-01T12:00:00Z</ContentDate>
<DeltaStart>2017-02-01T12:00:00Z</DeltaStart>
</header>
Here's the error message:
Assertion evaluation ('emtpy(dateTime(./DeltaStart) gt dateTime(./ContentDate))') for element 'LEIHeader' on schema type 'LEIHeaderType' did not succeed.
XPST0017 - Function does not exist: emtpy arity: 1.
My guess would be that you misspelled "empty" as "emtpy". Either that, or it's a very strange error message.
(But applying the empty() function to the result of a "gt" comparison also seems a bit... shall we say quirky?)

XSD 1.1 assert to compare dates

I wrote a number of assertions to compare pairs of dates in XSD 1.1 but none of them work.
Examples:
INPUT
<Records content-date="2006-05-04T18:13:51.0Z">
<Record issuance-date="2006-05-04T18:13:51.0Z"
last-update-date="2006-05-04T18:13:51.0Z"
last-renewal-date="2006-05-04T18:13:51.0Z" >
</Record>
<Record issuance-date="2006-05-04T18:13:51.0Z"
last-update-date="2006-05-04T18:13:51.0Z" last-renewal-date="2006-05-04T18:13:51.0Z">
<Event event-date="2006-05-04T18:13:51.0Z" event-type="INITIAL_REGISTRATION">
</Event>
</Record>
</Records>
XSD 1.1 asserts:
<xs:assert id="plausibility-issuance-date-plausibility"
test="#issuance-date < ./#content-date"/>
and
<xs:assert id="plausibility-file-and-record-timezones"
test="timezone-from-dateTime(Record/#issuance-date) = timezone-from-dateTime(REcords#content-date)"/>
Having read up on dateTime and timezone representations I'm a little overwhelmed.
Can anyone please tell me:
where are the errors (I hope it's clear what I'm trying to compare)?
is there a set of simple examples of this kind that make it easier to follow?
Your xs:assert XPATH its not correct because it is assumming that issuance-date and content-date are attributes of the same element, but they are not.
You can use an assert with this sample XPATH to say that "there is no Record with issuance-date greater or equal than its parent content-date":
empty(Record[#issuance-date ge ../#content-date])
Example XSD:
<xs:element name="Records">
<xs:complexType>
<xs:sequence>
<xs:element name="Record" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="issuance-date" type="xs:dateTime"/>
<xs:attribute name="last-update-date" type="xs:dateTime"/>
<xs:attribute name="last-renewal-date" type="xs:dateTime"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="content-date" type="xs:dateTime"/>
<xs:assert id="plausibility-issuance-date-plausibility" test="empty(Record[#issuance-date ge ../#content-date])"/>
</xs:complexType>
</xs:element>

How to declare optional date field in XSD

I was using XSD to validate my incoming XML elements.
XSD File
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.rg/2001/XMLSchema"
xmlns:tns="http://xxxy/ervices/V0"
targetNamespace="http://xxxy/ervices/V" elementFormDefault="qualified"
attributeFormDefault="unqualified" >
<xs:complexType name="FailType">
<xs:sequence>
<xs:element name="ConDt" type="xs:date" minOccurs="0" maxOccurs="1" nillable="true"/>
<xs:element name="PreEn" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
My XML File
<Pat xmlns="http://xxxy/ervices/V">
<ConDt></ConDt>
</Pat>
I was getting element is invalid - The value '' is invalid according to its datatype 'http://org/2001/XMLSchema:date' - The string '' is not a valid Date value.
Specifying nillable="true" allows your instance to contain
<ConDt xsi:nil="true"></ConDt>
but it doesn't allow you to write
<ConDt></ConDt>
(Please don't ask me what they were thinking...)
If you want to allow
<ConDt></ConDt>
Then two possible approaches are
define it as a union type that allows either an xs:date or a
zero-length string, or
(my preferred approach) define it as a list type: a list of xs:date values with maxLength="1".
Thanks a lot Michael. I really appreciate your help.
Below code will allow us to declare optional date field.
<xs:element name="ConDt" maxOccurs="unbounded" minOccurs="0">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
<xs:maxLength value="0" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:date" />
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>

Why can i promote property fields in BizTalk 2006 but distinguished fields are disabled?

I have a very strange behaviour in the Show Promotions Dialog in BizTalk 2006. It allows me to promote property fields:
But distinguished fields are disabled:
Any thoughts?
This is the XML Schema generated by the SQL Transport Schema Generation Wizard:
<?xml version="1.0" encoding="utf-16" ?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://ExecutionPlanner.InitializeStep" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ExecutionPlanner.InitializeStep" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<msbtssql:sqlScript value="exec [InitizializeStep] #ORCHESTRATION_NAME=" ", #PROVIDER_NAME=" ", #STEP_NAME=" "" xmlns:msbtssql="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element name="Step">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="OrchestrationID" type="OrchestrationIDType" />
<xs:element name="Message" type="MessageType" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="OrchestrationIDType">
<xs:simpleContent>
<xs:extension base="xs:string" />
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="MessageType">
<xs:simpleContent>
<xs:extension base="xs:string" />
</xs:simpleContent>
</xs:complexType>
</xs:schema>
Edit your schema to change the OrchestrationID field from a Record to a Field Element. Only Elements and Attributes can be distinguished.
This usually entails deleting the existing Record element, then re-creating an Element with the same name, as Visual Studio wont allow changing an xml node's type. However, you can get around this by opening the xsd file using the XML (Text) Editor using the 'Open With...' option.

Resources