xsd to xml robot task
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: xsd to xml robot task

Hybrid View

  1. #1
    Join Date
    Feb 2011
    Posts
    5

    Question xsd to xml robot task

    Hi, I am an engineering student seeking some advice, since my programming experience is very limited.

    Task to be done:
    I have to create xml files to be used in a robot simulation program (DELMIA). These files contain data of the tasks the robots must carry out, e.g. names of parts to be grabbed, x,y,z positions to move to etc.
    This should be done automatically, based on data from an external source not determined yet, but I am thinking database, excel or .csv.
    Several files would have to be created every day, so minimal human interaction is preferable.

    The xml file can vary depending on e.g. the number of tasks the robot must run through. So an element and sub-elements in the xml file can occur several times with different attribute values for each instance. (One xml file might tell the robot to pick and place 3 parts and then weld them)

    I have a xsd file at my disposal. (attached as txt file)

    Question:
    I have been searching the net the last couple of days, and have come across a few possibilities. I would like some advice on which would be the easiest and best for the task at hand, if they can do the job at all, or if there is something better around?

    1) xsd.exe and serialization
    - creating a class file from the xsd and using it to piece together a custom xml file in some way.

    The info I have on these two seems mainly to be about changing existing xml files and creating xml files by hand. But I could easily be wrong

    2) XPath

    3) LINQ to XML

    I hope you have some insight on what direction is the easiest for me to continue?

    Best Regards
    Anders
    Attached Files Attached Files

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    Re: xsd to xml robot task

    Do you have a sample of the xml?

  3. #3
    Join Date
    Feb 2011
    Posts
    5

    Re: xsd to xml robot task

    This is a file exported from the simulation program. There is just a few Activity elements in the ActivityList which describes the robot movements.

    In reality the xml files to be created would maybe have more than 100.

    Thanks for taking an interest in this, I really appreciate it.
    Attached Files Attached Files

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    Re: xsd to xml robot task

    The approach I would take is to use Xml Serialization. Check out my response in this thread: http://www.codeguru.com/forum/showthread.php?t=507807

    Take a portion of the xml file and try to serialize it.

    See if you can do it. Post back if you run into trouble.

  5. #5
    Join Date
    Feb 2011
    Posts
    5

    Re: xsd to xml robot task

    I ran into trouble

    Is there a clever way to handle "nested" elements?

    ResourceType is located inside OLPData, but how do I get both of them out in the same xml structure?

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Serialization;
    using System.IO;
    
    class Program
    {
        static void Main(string[] args)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(OLPData));
            TextWriter writer = new StreamWriter("Delmia file.xml");
            OLPData olpData = new OLPData();
            olpData.Context = "Some context";
            olpData.DownloaderRootDirectory = "Some download directory";
            olpData.LogFileName = "Some filename";
    
            ResourceType resourceType = new ResourceType();
            resourceType.id = "Some id";
    
            serializer.Serialize(Console.Out, olpData);
            Console.Read();
        }
    }

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    Re: xsd to xml robot task

    What do your classes and xml related attributes look like?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center