HI all,
I am trying to define a schema for the folder/file hierarchy
just as in a normal directory/file system.
I don't seem to be able to get the right way to define a
nested relationship between a folder and its subfolders.
I have the following XML instance shown
<Drive>
<Folder Name="MyFolder">
<File>My1.txt</File>
<File>My2.txt</File>
<Folder Name="FolderA1">
<Folder Name="AnotherFolderInsideSubFolder">
<File>My3.txt</File>
<File>My4.txt</File>
</Folder>
</Folder>
</Folder>
</Drive>
I started out by defining the following schema. I am not sure how to define
the nested
relationship between the Folder and its sub folders (the Folder element).
<xs:schema xmlns="http://MyCompany/FolderView.xsd"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://MyCompany/FolderView.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Drive">
<xs:complexType>
<xs:sequence>
<xs:element name="Folder" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="File" type="xs:string" minOccurs="0"
maxOccurs="unbounded" />
<xs:element name="Folder" type="Folder" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="Name" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
When I try to run the XSD utility (in the .NET framework to
generate the XMl erialization classes
xsd.exe folder.xsd /classes,
I get the following error:
"Schema validation warning: Type 'http://MyCompany/FolderView.xsd:Folder' is
not
declared. An error occurred at file:///C:/Documents and
Settings/Darren/Desktop
/Folder.xsd, (12, 9)"
Can you please point me to how I should fix the schema to
define the nested relationship (recursive) between the folder
and its subfolders.
Thanks,
Darren
Colin Savage - 24 Oct 2003 08:04 GMT
See comments below
> HI all,
>
[quoted text clipped - 35 lines]
> <xs:element name="File" type="xs:string" minOccurs="0"
> maxOccurs="unbounded" />
The error is caused by the next line, because the ComplexType Folder is not
declared at the global level of the schema
> <xs:element name="Folder" type="Folder" minOccurs="0"
> maxOccurs="unbounded" />
[quoted text clipped - 24 lines]
> Thanks,
> Darren
you should declare FileType and FolderType as named global complex types.
Then your elements become:
<xs:element name="Folder" type="FolderType" minOccurs...etc
Colin
name - 24 Oct 2003 08:30 GMT
It is all one and the same
see MS databinding
the way they treat attributes and text nodes.
===========
Basically go over the file system
get your props.
if it says folder make an attribute or textNode
ir it says file make an attribute or textNode (flag)
======
You don't even need the elements named differently
or meaning full at all, since there are only 2 ways,
intrinsically or per 'gravity'.
Since a node 'file' has no child 'folder'
pretty easy ain't.
======
And why not have the textNode be the document itself
and handle the structure as mentioned above attributed.
What do you think?
++++++++++++++
<d driveAttributes="here">
<fi/>
<fi/>
<fo folderAttributes="here">
<fi fileAttributes="here">
------paragraph, format markup here------
treasury Island By Johan Swift
blah.
internal pointer e.g <href="his dog ate what?"
-------other render markup here---------
</fi>
<fi/>
<fi/>
<fi/>
<fi/>
</fo>
<fo/>
<fo/>
<fo/>
<fo/>
</d>
these are 8 integers (true nodes) or numbers 1 - 8, or 64 bytes.
Given a Huffman or so redux compression, it be nothing for fo/fi node
pointers
5 million Files and Folder pointers be no more than 5 MB,
given a 1 byte follow flag instead of absolute childNumber 2,305,214
You sure want to read the attributes at runtime from file system raw data
address sector
or your XML becomes bloatware.
So for you higher level call you need absolute child number and anchestor
relations integer.
which is a small indexable food for CPU and Hardware Caches.
This would be architected in a jiffy, if it were not for the greed
and intolerance for everything not money or submissive.
Must be that the responsible royalties need hang out in Iraq and on Mars.
Good luck anyway with your project.
--------
> HI all,
>
[quoted text clipped - 63 lines]
> Thanks,
> Darren
Jan Shimkus - 24 Oct 2003 19:58 GMT
try this
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Drive">
<xs:complexType>
<xs:sequence>
<xs:element ref="Folder" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="File" type="xs:string"/>
<xs:element name="Folder">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="Folder" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="File" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
<xs:attribute name="Name" use="required">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN"/>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
Jan
> HI all,
>
[quoted text clipped - 63 lines]
> Thanks,
> Darren
Darren S - 28 Oct 2003 17:49 GMT
Thanks everyone.
Your suggestions helped solve my problem.
> HI all,
>
[quoted text clipped - 63 lines]
> Thanks,
> Darren