[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSD pattern facet that prohibits a simple type from containing acertain

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Fri, 29 Nov 2019 17:12:00 +0000

XSD pattern facet that prohibits a simple type from containing acertain

Hi Folks,

 

Below is an excerpt of an XHTML document. It shows a <style> element. The content of the <style> element is printable ASCII text. I created this element declaration:

 

<xs:element name="style">
   
<xs:simpleType>
       
<xs:restriction base="xs:string">
           
<xs:maxLength value="40000" />
           
<xs:pattern value="[\s&#x20;-&#x7E;]*" />
       
</xs:restriction>
   
</xs:simpleType>
</xs:element>

 

But that is not sufficient. For my situation, a valid style element will not contain a <link> element inside the style element’s CDATA section. That is, if the style element is valid, the style element will not contain this:

 

<style>
    
<![CDATA[
       <link href="" type="text/css" rel="stylesheet" />
      ...
      -->]]>
</style>

 

Is there a way in XML Schema 1.0 to express the restriction: The value of the style element is a string, excluding &lt;link?

 

Perhaps a pattern facet with a regex like this:

 

<xs:pattern value="[\s&#x20;-&#x7E;-[(&lt;link0]]*" />

 

However, that’s not a legal regex.

 

I can express the restriction using Schematron:

 

<sch:assert test="not(matches(normalize-space(.), '.*&lt;link.*', 'i'))">
    …
</sch:assert>

 

But I would rather do all checking in XML Schema if possible.

 

Also, I could implement the restriction in XML Schema 1.1 using an xs:assert, but I would rather use XML Schema 1.0 if possible.

 

Is it possible to express the restriction in XML Schema 1.0?  /Roger

Excerpt of an XHTML document

 

<style>
    
<![CDATA[
      <!--
      /* Font Definitions */
      @font-face
      {
          font-family: "Cambria Math";
          panose-1: 2 4 5 3 5 4 6 3 2 4;
      }
      @font-face
      {
          font-family: Calibri;
          panose-1: 2 15 5 2 2 2 4 3 2 4;
      }
      /* Style Definitions */
      p.MsoNormal,
      li.MsoNormal,
      div.MsoNormal
      {
          margin: 0in;
          margin-bottom: .0001pt;
          font-size: 11.0pt;
          font-family: "Calibri", sans-serif;
      }
      a:link,
      span.MsoHyperlink
      {
          mso-style-priority: 99;
          color: #0563C1;
          text-decoration: underline;
      }
      a:visited,
      span.MsoHyperlinkFollowed
      {
          mso-style-priority: 99;
          color: #954F72;
          text-decoration: underline;
      }
      span.EmailStyle17
      {
          mso-style-type: personal-compose;
          font-family: "Calibri", sans-serif;
          color: windowtext;
      }
      .MsoChpDefault
      {
          mso-style-type: export-only;
          font-family: "Calibri", sans-serif;
      }
      @page WordSection1
       {
          size: 8.5in 11.0in;
          margin: 1.0in 1.0in 1.0in 1.0in;
      }
      div.WordSection1
      {
          page: WordSection1;
      }
      -->]]>
</style>

 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.