On Mar 2, 4:02 pm, Joseph Kesselman <keshlam-nos...@comcast. net>
wrote:
roy axenov wrote:
(I think some selfless hero should step forward and start
a ctx FAQ.
Well, there are a lot of other XML FAQs out there, so the first thing to
do would be to point to those... but, yeah, that thought has occurred to
me. Certainly that's how the XSL FAQ was assembled.
The most elegant solution (least effort for any one person, though
conversely least credit to any one person) would be to find a Wiki
somewhere that's willing to host this FAQ, and build it up collaboratively .
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
I used the <xsd:uniqueat collection level to inspect the children
for distinctness:
Here is my final solution that works in case anyone is interested, my
code is spread over several include files so I'll just paste each with
the file name in upper case preceeding that files contents: (3 files
follow, the test file is last and makes ref to the songs.xsd file, and
songs.xsd includes by ref my global types)
SONGS.XSD
------------------------
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" >
<xs:include schemaLocation= "types.xsd" />
<xs:element name="Songs" type="typeSongs ">
<xs:unique name="keyTitle" >
<xs:selector xpath="Song"/>
<xs:field xpath="Title"/>
</xs:unique>
</xs:element>
</xs:schema>
TYPES.XSD
------------------------
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefa ult="qualified" >
<!-- Simple Types -->
<xs:simpleTyp e name="typeTitle ">
<xs:restricti on base="xs:string ">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="typeFileP ath">
<xs:restricti on base="xs:string ">
<xs:whiteSpac e value="preserve "/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="typeFitPa ge">
<xs:restricti on base="xs:string ">
<xs:enumerati on value="HEIGHT"/>
<xs:enumerati on value="WIDTH"/>
<xs:enumerati on value="Height"/>
<xs:enumerati on value="Width"/>
<xs:enumerati on value="height"/>
<xs:enumerati on value="width"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="typeRatin g">
<xs:restricti on base="xs:intege r">
<xs:minInclusiv e value="1"/>
<xs:maxInclusiv e value="5"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="typeVolum e">
<xs:restricti on base="xs:intege r">
<xs:minInclusiv e value="0"/>
<xs:maxInclusiv e value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="typeBalan ce">
<xs:restricti on base="xs:intege r">
<xs:minInclusiv e value="-100"/>
<xs:maxInclusiv e value="100"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="typeTimeS ignature">
<xs:restricti on base="xs:string ">
<xs:pattern value="[123456789][/][123456789]"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="typeKey">
<xs:restricti on base="xs:string ">
<xs:enumerati on value="A Maj"/>
<xs:enumerati on value="A# Maj"/>
<xs:enumerati on value="Bb Maj"/>
<xs:enumerati on value="B Maj"/>
<xs:enumerati on value="B# Maj"/>
<xs:enumerati on value="C Maj"/>
<xs:enumerati on value="C# Maj"/>
<xs:enumerati on value="Db Maj"/>
<xs:enumerati on value="D Maj"/>
<xs:enumerati on value="D# Maj"/>
<xs:enumerati on value="Eb Maj"/>
<xs:enumerati on value="E Maj"/>
<xs:enumerati on value="E# Maj"/>
<xs:enumerati on value="F Maj"/>
<xs:enumerati on value="F# Maj"/>
<xs:enumerati on value="Gb Maj"/>
<xs:enumerati on value="G Maj"/>
<xs:enumerati on value="G# Maj"/>
<xs:enumerati on value="Ab Maj"/>
<xs:enumerati on value="A Min"/>
<xs:enumerati on value="A# Min"/>
<xs:enumerati on value="Bb Min"/>
<xs:enumerati on value="B Min"/>
<xs:enumerati on value="B# Min"/>
<xs:enumerati on value="C Min"/>
<xs:enumerati on value="C# Min"/>
<xs:enumerati on value="Db Min"/>
<xs:enumerati on value="D Min"/>
<xs:enumerati on value="D# Min"/>
<xs:enumerati on value="Eb Min"/>
<xs:enumerati on value="E Min"/>
<xs:enumerati on value="E# Min"/>
<xs:enumerati on value="F Min"/>
<xs:enumerati on value="F# Min"/>
<xs:enumerati on value="Gb Min"/>
<xs:enumerati on value="G Min"/>
<xs:enumerati on value="G# Min"/>
<xs:enumerati on value="Ab Min"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleTyp e name="typeMessa ge">
<xs:restricti on base="xs:string ">
<xs:whiteSpac e value="preserve "/>
<xs:maxLength value="500"/>
</xs:restriction>
</xs:simpleType>
<!-- Complex (1 level) Types -->
<xs:complexTy pe name="typeSongD ata">
<xs:sequence>
<xs:element name="Title" type="typeTitle "/>
<xs:element name="Audio" type="typeFileP ath"/>
<xs:element name="Sheet" type="typeFileP ath"/>
<xs:element name="Page" type="xs:positi veInteger" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Composers " type="xs:string " minOccurs="0"
maxOccurs="1"/>
<xs:element name="FitPage" type="typeFitPa ge" minOccurs="0"
maxOccurs="1"/>
<xs:element name="StartAt" type="xs:time" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Keywords" type="xs:string " minOccurs="0"
maxOccurs="1"/>
<xs:element name="GeneralRa ting" type="typeRatin g" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Difficult yRating" type="typeRatin g" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Rehearsal Rating" type="typeRatin g" minOccurs="0"
maxOccurs="1"/>
<xs:element name="TimeSigna ture" type="typeTimeS ignature"
minOccurs="0" maxOccurs="1"/>
<xs:element name="Key" type="typeKey" minOccurs="0" maxOccurs="1"/>
<xs:element name="TempoBPM" type="xs:positi veInteger" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Volume" type="typeVolum e" minOccurs="0"
maxOccurs="1"/>
<xs:element name="Balance" type="typeBalan ce" minOccurs="0"
maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<!-- Complex (2 level) Types -->
<xs:complexTy pe name="typeSong" >
<xs:sequence>
<xs:element name="Song" type="typeSongD ata"/>
</xs:sequence>
</xs:complexType>
<!-- Complex Collection Types -->
<xs:complexTy pe name="typeSongs ">
<xs:sequence>
<xs:element name="Song" type="typeSongD ata" minOccurs="0"
maxOccurs="unbo unded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
SONGS.XML (this test file will fail with a duplicate Title)
------------------------------------------------------------------------------------
<Songs xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "Schema/songs.xsd">
<Song>
<Title>One</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<Composers>Jobi m</Composers>
<Keywords>Latin ,Cuban,Slow</Keywords>
<GeneralRating> 3</GeneralRating>
<DifficultyRati ng>3</DifficultyRatin g>
<RehearsalRatin g>3</RehearsalRating >
</Song>
<Song>
<Title>a song</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<FitPage>widt h</FitPage>
</Song>
<Song>
<Title>Route 66 Hal Leonard Best of Swing 13</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<FitPage>widt h</FitPage>
</Song>
<Song>
<Title>the song</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<FitPage>widt h</FitPage>
</Song>
<Song>
<Title>Two</Title>
<Audio>Route 66 Hal Leonard Best of Swing 13.wma</Audio>
<Sheet>IACRefer ence.pdf</Sheet>
<Page>1</Page>
<FitPage>height </FitPage>
<StartAt>00:00: 03</StartAt>
<Keywords>swing ,road</Keywords>
<GeneralRating> 4</GeneralRating>
<DifficultyRati ng>4</DifficultyRatin g>
<RehearsalRatin g>4</RehearsalRating >
<TimeSignature> 4/4</TimeSignature>
<Key>F Maj</Key>
<TempoBPM>120 </TempoBPM>
<Volume>100</Volume>
<Balance>0</Balance>
</Song>
<Song>
<Title>Three</Title>
<Audio>hw2.wa v</Audio>
<Sheet>IACRefer ence.pdf</Sheet>
<Page>11</Page>
</Song>
<Song>
<Title>Four</Title>
<Audio>hw1xxxx. wav</Audio>
<Sheet>testcute pdfXXXX.pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>Five</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>Six</Title>
<Audio>hw2.wa v</Audio>
<Sheet>nabble_j avascript_error .pdf</Sheet>
<Page>1</Page>
</Song>
<Song>
<Title>a song</Title>
<Audio>hw1.wa v</Audio>
<Sheet>testcute pdf.pdf</Sheet>
<Page>2</Page>
<FitPage>widt h</FitPage>
</Song>
</Songs>