Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming,microsoft.public.office.xml,microsoft.public.vsnet.vstools.office
|
|||
|
|||
Validating data at data entry and XSD
Hi,
Apologies for the multi-post; I am not sure where this question belongs. I am fairly new to XML. I have an XML Schema that includes restrictions (such as data types, valid values, data length ...) - see snippet below Although Excel will validate the data against the schema at save time, I need real-time validation. I thought it might be possible to achieve this with some vba code byu copying the restrictions to Excel's own validation. I can import(Add) the schema into an XML map, but then I don't know how to read the schema to set the data validation The example in the help file is not very helpful - or it indicates that the programmer must know the schema before addng it to an XML Map. The pseudo code for what I want to achieve is import schema file create list object for each element or attribute in schema, map to column read element restrictions add column validation - this may not be fully implementable as XSD schema restrictions can be fairly powerful move to next column next element Thanks in advance for any suggestions /advice HS -------------------------------- <?xml version="1.0" encoding="UTF-8"? <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" <xsd:element name="Dalexml" nillable="true" <xsd:complexType <xsd:sequence minOccurs="0" <xsd:element name="inventoryItem" form="unqualified" nillable="true" minOccurs="0" maxOccurs="unbounded" <xsd:complexType <xsd:sequence <xsd:element name="handle" minOccurs="0"/ <xsd:element name="name" form="unqualified" nillable="true" minOccurs="0" <xsd:simpleType <xsd:restriction base="xsd:string"/ </xsd:simpleType </xsd:element <xsd:element name="displayName" form="unqualified" nillable="true" minOccurs="0" <xsd:simpleType <xsd:restriction base="xsd:string" <xsd:maxLength value="60"/ <xsd:minLength value="1"/ <xsd:whiteSpace value="preserve"/ </xsd:restriction </xsd:simpleType </xsd:element <!-- snip remaining elements -- </xsd:sequence </xsd:complexType </xsd:element </xsd:sequence </xsd:complexType </xsd:element </xsd:schema ----------------------------- strSchemaLocation = "C:\temp\testschema3.xsd" ActiveWorkbook.XmlMaps.Add(strSchemaLocation, "Dalexml").Name = "Dalexml_Map" ' Specify the schema map to use. Set InvMap = ActiveWorkbook.XmlMaps("Dalexml_Map") ' Create a new list. Set lstInv = ActiveSheet.ListObjects.Add ' Specify the first element to map.Can I "extract" the path for dynamic mapping? strXPath = "/Dalexml/inventoryItem/Name" ' <<< do I have to know the path? ' Map the element. lstContacts.ListColumns(1).XPath.SetValue InvMap, strXPath |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Data Entry Online, Data Format, Data Conversion and Data EntryServices through Data Entry Outsourcing | Excel Discussion (Misc queries) | |||
Connecting of two data validating with each other | Excel Worksheet Functions | |||
Validating entry in ComboBox | Excel Discussion (Misc queries) | |||
Validating excel entry... | Excel Programming | |||
Validating Entry into Textbox | Excel Programming |