473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

XML format enforcement

I wish to write some kind of XML format enforcer like DTD, XSD or other that
can do the following:
(1) Any element and node must have Type attribute that can be read as data
type by the parser.
(1) Any element and node may have (optional) four more attributes.

I XML enforcer should allow any tree structure and any number of nodes in
any tree.

Does anyone can tell how it's possible?

Any example will be most appreciated.
--
Thanks
Sharon
Oct 23 '06 #1
5 1522
Sharon,
It certainly can be done. Visual Studio 2005 can use XSD, but not DTD;
has methods for attaching external xsd's or you can place the xsd
inline in the code. Check out the VS documentation. w3.org has
specifications etc.
Robert

Sharon wrote:
I wish to write some kind of XML format enforcer like DTD, XSD or other that
can do the following:
(1) Any element and node must have Type attribute that can be read as data
type by the parser.
(1) Any element and node may have (optional) four more attributes.

I XML enforcer should allow any tree structure and any number of nodes in
any tree.

Does anyone can tell how it's possible?

Any example will be most appreciated.
--
Thanks
Sharon
Oct 23 '06 #2
Thanks Robert for your reply.

I know that XSD can be attached to an XML file, but I don't know how the SAD
should look like in order to enforce the formatting I have posted.

Can you post en example showing this?

P.S.: I'm using VS 2003.
--
Thanks
Sharon
Oct 23 '06 #3
Here is a public dtd issued for xml ucc filings:

http://72.14.203.104/search?q=cache:...s&ct=clnk&cd=4

with that, you can get it converted with a dtd to xsd converter.
Bob

Sharon wrote:
Thanks Robert for your reply.

I know that XSD can be attached to an XML file, but I don't know how the SAD
should look like in order to enforce the formatting I have posted.

Can you post en example showing this?

P.S.: I'm using VS 2003.
--
Thanks
Sharon
Oct 23 '06 #4
It seems that ant DTD or XSD defining the node name (parameter name in my
case), and this not good for me.

I need to let the user enter any node name he likes, but I do want to force
him to use my predefined attributes.
And I can't not find a way to do that.

Is there ?
--
Thanks
Sharon
Oct 25 '06 #5
Ok, I think I found a way to do thanks to Marc Clifton articale on
CodeProject (http://www.codeproject.com/dotnet/MycroXaml.asp).

The XML file can be somthing like that:

<?xml version="1.0" encoding="utf-8"?>
<System Name="System">
<Paramaters>
<Speed type="System.Iint32">111</Speed >
<_xAxis type="System.Single">222</_xAxis>
<_yAxis type="System.Double">333</_yAxis>
<_ID type="System.Int64">444</_ID>
<_Name type="System.String">String value...</_Name>
</Paramaters>
</System>
And the C# code can be:

System.IO.StreamReader sr = new System.IO.StreamReader("TypesDef.xml");
string text = sr.ReadToEnd();
sr.Close();
XmlDocument doc = new XmlDocument();
doc.LoadXml(text);
XmlNode node = doc.FirstChild;
while( node.NodeType.ToString() != "Element" )
{
node = node.NextSibling;
}

XmlNode paramsNode = doc.SelectSingleNode("//Paramaters");
XmlNodeList nodeList = paramsNode.ChildNodes;
Hashtable verTypes = new Hashtable(nodeList.Count);
string typeName = "";
Type type;

foreach( XmlNode xmlNode in nodeList )
{
XmlAttribute attr = xmlNode.Attributes["type"];
typeName = attr.Value;
if( typeName == "System.String" )
{
verTypes[xmlNode.Name] = xmlNode.InnerText;
}
else
{
type = Type.GetType(typeName, false);
object typeIntance = Activator.CreateInstance(type);
System.Reflection.MethodInfo Parse = type.GetMethod("Parse", new Type
[] {typeof(String)});
verTypes[xmlNode.Name] = Parse.Invoke(type, new object[]
{xmlNode.InnerText});
}
}

------
Regards
Sharon
Nov 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rob Long | last post by:
Hey I've noticed a somewhat annoying feature in PHP5 when it comes to extended classes and types. If I declare an interface and a class that implements it, I get a "compile" error (read parse...
4
by: Florian Preknya | last post by:
I work on building a metamodel from an UML diagram (serialized as xmi). There I have a class called Class that represents a class from the UML model. The Class has a name member and ininitially it...
0
by: Vikas | last post by:
I am working on an application to be written in C++ which has to read a binary file and parse it to get the data out of it. The file format is Integrated Product Message (IPM) which contains...
15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
3
by: stevek | last post by:
How do I format an integer. Add commas. 1234565 1,234,565 TIA
6
by: Dario Di Bella | last post by:
Hi all, we have the following urgent issue affecting our development team. Initially we had one particular workstation that failed executing queries on a DB2 database, raising an invalid date...
9
by: (Pete Cresswell) | last post by:
Seems like when there's a 1:1 relationship, the order of referential integrity enforcement depends on which way you drag the mouse pointer when drawing the relationship line. If you drag from...
11
by: Grumble | last post by:
Hello, I have the following structure: struct foo { char *format; /* format string to be used with printf() */ int nparm; /* number of %d specifiers in the format string */ /* 0 <= nparm <=...
7
by: Edward Mitchell | last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a format of Time. The controls are all embedded in dialogs. I created the controls by dragging the DateTime picker from...
3
by: Sharon | last post by:
I wish to write some kind of XML format enforcer like DTD, XSD or other that can do the following: (1) Any element and node must have Type attribute that can be read as data type by the parser....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.