INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

xsd restriction error when validating xml

xsd restriction error when validating xml

(OP)
Hi All,

Trying to validate xml file, however xsd restriction error results. Data should be valid for this rule though(any number of alphanumeric characters - up to 40 max).

Thoughts? Thx Robert

ERROR: Element 'patient-id': [facet 'pattern'] The value 'str1234' is not accepted by the pattern '^[a-zA-Z0-9]+$'.
ERROR: Element 'patient-id': 'str1234' is not a valid value of the local atomic type.


XML:
<?xml version="1.0" encoding="utf-8"?>
<submission type="OUTPATIENT" data="str1234" version="123.45" action-code="ADD">
<provider>
<provider-id>str123</provider-id>
<npi>str1234</npi>
<patient>
<birthdate>08-01-2016</birthdate>
<sex>str1234</sex>
<race>str1234</race>
<ethnic>str1234</ethnic>
<postal-code>str1234</postal-code>
<attesting_physician_code>str1234</attesting_physician_code>
<attesting_physician_specialty_code>str1234</attesting_physician_specialty_code>
<principal_procedure_physician_code>str1234</principal_procedure_physician_code>
<first-name>str1234</first-name>
<last-name>str1234</last-name>
<encounter measure-set="str1234">
<encounter-date>08-01-2016</encounter-date>
<arrival-time>str1234</arrival-time>
<patient-id>str1234</patient-id>
<medical-record-number>str1234</medical-record-number>
<pthic>str1234</pthic>
<detail answer-code="str1234" row-number="1234" question-cd="str1234">
<answer-value>str1234</answer-value>
</detail>
</encounter>
</patient>
</provider>
</submission>

XSD:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="submission">
<xs:complexType>
<xs:sequence>
<xs:element name="provider" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="provider-id" minOccurs="1" maxOccurs="1" >
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="6" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="npi" type="xs:string" maxOccurs="1" minOccurs="0" />
<xs:element name="patient" maxOccurs="unbounded" minOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="birthdate" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])-([0-9][0-9][0-9][0-9])"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="sex" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="race" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="ethnic" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="postal-code" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="attesting_physician_code" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="attesting_physician_specialty_code" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="principal_procedure_physician_code" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="first-name" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="last-name" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="encounter" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="encounter-date" minOccurs="1" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])-([0-9][0-9][0-9][0-9])"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="arrival-time" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="8"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="patient-id" minOccurs="1" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="40"/>
<xs:pattern value="^[a-zA-Z0-9]+$"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="medical-record-number" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="15"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="pthic" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element maxOccurs="unbounded" name="detail" minOccurs="0">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:element name="answer-value" type="xs:string" />
</xs:sequence>
<xs:attribute name="answer-code" type="xs:string" use="required" />
<xs:attribute name="row-number" type="xs:integer" use="required" />
<xs:attribute name="question-cd" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="measure-set" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="OUTPATIENT"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="data" type="xs:string" use="required" />
<xs:attribute name="version" type="xs:decimal" use="required" />
<xs:attribute name="action-code" use="required" >
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ADD"/>
<xs:enumeration value="DELETE"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>


RE: xsd restriction error when validating xml

XSD pattern does not support the beginning and end of string anchors. It will probably work as expected by removing the caret and dollar symbols.

Tom Morrison
Consultant

RE: xsd restriction error when validating xml

(OP)
Thank You. This works. XSD was from a third party.

Much appreciated.

Robert

RE: xsd restriction error when validating xml

You are quite welcome, Robert. Welcome to Tek-Tips!

Tom Morrison
Consultant

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close