Jump to content

craigewens

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by craigewens

  1. Marvellous! thank you very much.I have incorporated the pattern update, I agree, it is much nicer.Thanks again for all your assistance!
  2. Thank you!I have taken on your advice and implemented.Here are my final amendmentsXML <SCAMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SCAMA - Schema.xsd"> <USERS> <USER>name1</USER> <USER>name2</USER> <USER>name3</USER> <USER>name4</USER> </USERS> <GROUPS> <GROUP id="group1"> <PORTS> <PORT id="port1"> <SOURCE_FILES> <FILE type="txt">c:\group1\port1\source_file1.txt</FILE> <FILE type="txt">c:\group1\port1\source_file2.txt</FILE> <FILE type="txt">c:\group1\port1\source_file3.txt</FILE> <FILE type="txt">c:\group1\port1\source_file4.txt</FILE> </SOURCE_FILES> <DEFINED_FREQS> <START_FREQ units="Hz">12000000000</START_FREQ> <STOP_FREQ units="Hz">12000000000</STOP_FREQ> <POINTS>801</POINTS> </DEFINED_FREQS> <DESTINATION type="txt">c:\group1\port1\dest_file1.txt</DESTINATION> </PORT> <PORT id="port2"> <SOURCE_FILES> <FILE type="txt">c:\group2\port2\source_file1.txt</FILE> <FILE type="txt">c:\group2\port2\source_file2.txt</FILE> </SOURCE_FILES> <FREQ_MASTER type="txt">c:\group2\port2\freq_master.txt</FREQ_MASTER> <DESTINATION type="txt">c:\group2\port2\dest_file1.txt</DESTINATION> </PORT> </PORTS> <INSTALL> <SOURCE>\\server\files\group1\</SOURCE> <DESTINATION>\\comp_1\files\</DESTINATION> </INSTALL> </GROUP> </GROUPS></SCAMA> XSD <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="SCAMA"> <xs:complexType> <xs:sequence> <xs:element ref="USERS"/> <xs:element ref="GROUPS"/> </xs:sequence> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="USERS"> <xs:complexType> <xs:sequence> <xs:element name="USER" type="NonBlankString" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="GROUPS"> <xs:complexType> <xs:sequence> <xs:element ref="GROUP" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="GROUP"> <xs:complexType> <xs:sequence> <xs:element ref="PORTS"/> <xs:element ref="INSTALL"/> </xs:sequence> <xs:attribute name="id" type="NonBlankString" use="required"/> </xs:complexType> </xs:element> <xs:element name="PORTS"> <xs:complexType> <xs:sequence> <xs:element ref="PORT" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="PORT"> <xs:complexType> <xs:sequence> <xs:element ref="SOURCE_FILES"/> <xs:choice> <xs:element ref="DEFINED_FREQS"/> <xs:element name="FREQ_MASTER" type="FILE"/> </xs:choice> <xs:element name="DESTINATION" type="FILE"/> </xs:sequence> <xs:attribute name="id" type="NonBlankString" use="required"/> </xs:complexType> </xs:element> <xs:element name="INSTALL"> <xs:complexType> <xs:sequence> <xs:element name="SOURCE" type="NonBlankString"/> <xs:element name="DESTINATION" type="NonBlankString"/> </xs:sequence> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="SOURCE_FILES"> <xs:complexType> <xs:sequence> <xs:element name="FILE" type="FILE" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="DEFINED_FREQS"> <xs:complexType> <xs:sequence> <xs:element name="START_FREQ" type="FREQS"/> <xs:element name="STOP_FREQ" type="FREQS"/> <xs:element name="POINTS" type="xs:integer"/> </xs:sequence> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:complexType name="FILE"> <xs:simpleContent> <xs:extension base="NonBlankString"> <xs:attribute name="type" type="FileType" use="required"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:complexType name="FREQS"> <xs:simpleContent> <xs:extension base="NonBlankString"> <xs:attribute name="units" type="UnitsEnumType" use="required"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:simpleType name="UnitsEnumType"> <xs:restriction base="NonBlankString"> <xs:enumeration value="Hz"/> <xs:enumeration value="kHz"/> <xs:enumeration value="MHz"/> <xs:enumeration value="GHz"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="FileType"> <xs:restriction base="NonBlankString"> <xs:enumeration value="txt"/> <xs:enumeration value="citi"/> <xs:enumeration value="hdf"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="NonBlankString"> <xs:restriction base="xs:string"> <xs:minLength value="1"/> <xs:whiteSpace value="collapse"/> </xs:restriction> </xs:simpleType></xs:schema>
  3. Once again, thank you for your help.I have heeded your comments and updated my xsd and xml file accordingly.XML <SCAMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SCAMA - Schema2.xsd"> <USERS size="4"> <USER>name1</USER> <USER>name2</USER> <USER>name3</USER> <USER>name4</USER> </USERS> <GROUPS size="1"> <GROUP id="group1"> <PORTS size="2"> <PORT id="port1" size="2"> <SOURCE_FILES size="4"> <FILE>c:\group1\port1\source_file1.txt</FILE> <FILE>c:\group1\port1\source_file2.txt</FILE> <FILE>c:\group1\port1\source_file3.txt</FILE> <FILE>c:\group1\port1\source_file4.txt</FILE> </SOURCE_FILES> <DEFINED_FREQS> <START_FREQ units="Hz">12000000000</START_FREQ> <STOP_FREQ units="Hz">12000000000</STOP_FREQ> <POINTS>801</POINTS> </DEFINED_FREQS> <DESTINATION>c:\group1\port1\dest_file1.txt</DESTINATION> </PORT> <PORT id="port2" size="2"> <SOURCE_FILES size="2"> <FILE>c:\group2\port2\source_file1.txt</FILE> <FILE>c:\group2\port2\source_file2.txt</FILE> </SOURCE_FILES> <FREQ_MASTER>c:\group2\port2\freq_master.txt</FREQ_MASTER> <DESTINATION>c:\group2\port2\dest_file1.txt</DESTINATION> </PORT> </PORTS> </GROUP> </GROUPS></SCAMA> XSD <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="SCAMA"> <xs:complexType> <xs:sequence> <xs:element ref="USERS"/> <xs:element ref="GROUPS"/> </xs:sequence> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="USERS"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="USER" type="NonBlankString" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="size" type="NonBlankString" use="required"/> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="GROUPS"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="GROUP"/> </xs:sequence> <xs:attribute name="size" type="xs:byte" use="required"/> </xs:complexType> </xs:element> <xs:element name="GROUP"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="PORTS"/> </xs:sequence> <xs:attribute name="id" type="xs:string" use="required"/> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="PORTS"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="PORT" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="size" type="xs:byte" use="required"/> </xs:complexType> </xs:element> <xs:element name="PORT"> <xs:complexType mixed="true"> <xs:sequence> <xs:element ref="SOURCE_FILES"/> <xs:choice> <xs:element ref="DEFINED_FREQS"/> <xs:element name="FREQ_MASTER" type="xs:string"/> </xs:choice> <xs:element name="DESTINATION" type="NonBlankString"/> </xs:sequence> <xs:attribute name="id" type="NonBlankString" use="required"/> <xs:attribute name="size" type="NonBlankString" use="required"/> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="DEFINED_FREQS"> <xs:complexType> <xs:sequence> <xs:element ref="START_FREQ"/> <xs:element ref="STOP_FREQ"/> <xs:element name="POINTS" type="xs:short"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="START_FREQ"> <xs:complexType mixed="true"> <xs:attribute name="units" type="UnitsEnumType" use="required"/> </xs:complexType> </xs:element> <xs:element name="STOP_FREQ"> <xs:complexType mixed="true"> <xs:attribute name="units" type="UnitsEnumType" use="required"/> </xs:complexType> </xs:element> <xs:element name="SOURCE_FILES"> <xs:complexType mixed="true"> <xs:sequence> <xs:element name="FILE" type="NonBlankString" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="size" type="NonBlankString" use="required"/> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:simpleType name="UnitsEnumType"> <xs:annotation> <xs:documentation>This is the enumeration of all the different type of Units</xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="Hz"/> <xs:enumeration value="kHz"/> <xs:enumeration value="MHz"/> <xs:enumeration value="GHz"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="NonBlankString"> <xs:restriction base="xs:string"> <xs:minLength value="1"/> <xs:whiteSpace value="collapse"/> </xs:restriction> </xs:simpleType></xs:schema> These two files now validate through XMLSpy which I presume is a good sign.Can you see any other issues with my XML? It's the first time I've had to define anything like this myself and it's going to be used as an input to an application I'm writing so i'd like to use best practices from the start.Craig.
  4. Thank you for your reply... i am using XML Spy to validate the XML and it didn't get as far as stating that i forgot the units part With regards to the choice section i believe we are misunderstanding what i wish to achieve.I wold like the port node to contain either a single element called <FREQ_MASTER> or three elements called <START_FREQ>, <STOP_FREQ> and <POINTS>.So the XML file i showed above has two different contents for PORT, of which both should be valid... i just can't get the schema to adhere to my desires.With regards to your comment about the , can you expand upon which elements would require this?Thank you once again for taking the time to assist.Craig.
  5. It is possible, instead of this line: <xs:attribute name="date" type="xs:date" use="required" form="qualified"/> you need to have something like this: <xs:attribute name="date" type="carType" use="required" form="qualified"/> then add this section somewhere: <xs:simpleType name="carType"> <xs:restriction base="xs:string"> <xs:enumeration value="Audi"/> <xs:enumeration value="Golf"/> <xs:enumeration value="BMW"/> </xs:restriction></xs:simpleType> Obviously carType is not what you need, but it's an example lifted right off the w3schools website...http://www.w3schools.com/schema/schema_facets.aspCraig.[edit]oh man! sorry i didn't realise how old this topic was... sorry the assistance is so late in coming, i presume you'd have sorted it by now[/edit]
  6. Hi all,Here is my XML file: <SCAMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SCAMA - Schema2.xsd"> <USERS size="4"> <USER>last_first1</USER> <USER>last_first2</USER> <USER>last_first3</USER> <USER>last_first4</USER> </USERS> <GROUPS size="1"> <GROUP id="group1"> <PORTS size="2"> <PORT id="port1" size="2"> <SOURCE_FILES size="4"> <FILE>c:\group1\port1\source_file1.txt</FILE> <FILE>c:\group1\port1\source_file2.txt</FILE> <FILE>c:\group1\port1\source_file3.txt</FILE> <FILE>c:\group1\port1\source_file4.txt</FILE> </SOURCE_FILES> <START_FREQ>12000000000</START_FREQ> <STOP_FREQ>12000000000</STOP_FREQ> <POINTS>801</POINTS> <DESTINATION>c:\group1\port1\dest_file1.txt</DESTINATION> </PORT> <PORT id="port2" size="2"> <SOURCE_FILES size="2"> <FILE>c:\group2\port2\source_file1.txt</FILE> <FILE>c:\group2\port2\source_file2.txt</FILE> </SOURCE_FILES> <FREQ_MASTER>c:\group2\port2\freq_master.txt</FREQ_MASTER> <DESTINATION>c:\group2\port2\dest_file1.txt</DESTINATION> </PORT> </PORTS> </GROUP> </GROUPS></SCAMA> and here is my schema: <?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="SCAMA"> <xs:complexType> <xs:sequence> <xs:element ref="USERS"/> <xs:element ref="GROUPS"/> </xs:sequence> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="USERS"> <xs:complexType> <xs:sequence> <xs:element name="USER" type="NonBlankString" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="size" type="NonBlankString" use="required"/> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="GROUPS"> <xs:complexType> <xs:sequence> <xs:element ref="GROUP"/> </xs:sequence> <xs:attribute name="size" type="xs:byte" use="required"/> </xs:complexType> </xs:element> <xs:element name="GROUP"> <xs:complexType> <xs:sequence> <xs:element ref="PORTS"/> </xs:sequence> <xs:attribute name="id" type="xs:string" use="required"/> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="PORTS"> <xs:complexType> <xs:sequence> <xs:element ref="PORT" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="size" type="xs:byte" use="required"/> </xs:complexType> </xs:element> <xs:element name="PORT"> <xs:complexType> <xs:sequence> <xs:element ref="SOURCE_FILES"/> <xs:choice> <xs:element ref="DEFINED_FREQS"/> <xs:element name="FREQ_MASTER" type="xs:string"/> </xs:choice> <xs:element name="DESTINATION" type="NonBlankString"/> </xs:sequence> <xs:attribute name="id" type="NonBlankString" use="required"/> <xs:attribute name="size" type="NonBlankString" use="required"/> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:element name="DEFINED_FREQS"> <xs:complexType> <xs:sequence> <xs:element ref="START_FREQ"/> <xs:element ref="STOP_FREQ"/> <xs:element name="POINTS" type="xs:short"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="START_FREQ"> <xs:complexType> <xs:attribute name="units" type="UnitsEnumType" use="required"/> </xs:complexType> </xs:element> <xs:element name="STOP_FREQ"> <xs:complexType> <xs:attribute name="units" type="UnitsEnumType" use="required"/> </xs:complexType> </xs:element> <xs:element name="SOURCE_FILES"> <xs:complexType> <xs:sequence> <xs:element name="FILE" type="NonBlankString" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="size" type="NonBlankString" use="required"/> </xs:complexType> </xs:element> <!-- ############################################################### --> <xs:simpleType name="UnitsEnumType"> <xs:annotation> <xs:documentation>This is the enumeration of all the different type of Units</xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="Hz"/> <xs:enumeration value="kHz"/> <xs:enumeration value="MHz"/> <xs:enumeration value="GHz"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="NonBlankString"> <xs:restriction base="xs:string"> <xs:minLength value="1"/> <xs:whiteSpace value="collapse"/> </xs:restriction> </xs:simpleType></xs:schema> The problem is that the choice aspect is not working correctly.Within the PORT element i would like to either have a FREQ_MASTER element or START_FREQ, STOP_FREQ and POINTS elements.Is it possible the way i'm trying to do this?I keep getting the error "Unexpected child element 'START_FREQ'.Please can some experts assist?Much thanksCraig.
  7. At first glance you are missing the XML declaration at the start of your schema.http://www.w3schools.com/schema/schema_howto.asp scroll down to get to the title "An XML Schema"
×
×
  • Create New...