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 -~]*"
/>
</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 <link?
Perhaps a pattern facet with a regex like this:
<xs:pattern
value="[\s -~-[(<link0]]*"
/>
However, that’s not a legal regex.
I can express the restriction using Schematron:
<sch:assert
test="not(matches(normalize-space(.),
'.*<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>