title: transform xml to alto xml using c#
body: <p>Hello again fellow programmers.</p>
  
  <p>I have a task where i need to convert the xml output of of omnipage18 to xml alto format.</p>
  
  <p>as of now, i'm using c# and linq to read the xml.</p>
  
  <p>but i don't know if the output is correct.</p>
  
  <p>i found a php code where it converts the <code>abby finereader sdk xml output</code> but my requirement is using <code>omnipage 18</code> and here is my question: </p>
  
  <p>after reading i found this <a href="http://www.loc.gov/standards/alto/v3/alto-3-1.xsd" rel="nofollow noreferrer">xsd file</a>
  and I've read that:</p>
  
  <blockquote>
    <p><code>XSD (XML Schema Definition) is a World Wide Web Consortium (W3C)
    recommendation that specifies how to formally describe the elements in
    an Extensible Markup Language (XML) document.</code></p>
  </blockquote>
  
  <p>My problem is I don't really understand how to use the XSD file. So how can I convert a omnipage xml to alto xml using what is written is the XSD file? . 
  And How can this XSD guide me to convert the xml file?</p>
  
  <p>XSD file is used to define the possible structure and contents of an XML format. But is how to use this as a guide to create an XSLT file?
  (sorry for this dumb question)</p>
  
  <p>As of now this is my c# code</p>
  
  <pre><code>private string OmnitoAlto(string fileName)
          {
              StringBuilder alto = new StringBuilder();
              try
              {
                  XDocument document = XDocument.Load(fileName);
  
                  var coordinates = from r in document.Descendants().Where(e =&gt; e.Name.LocalName == "wd")
                                    select new
                                    {
                                        HPOS = r.Descendants().Where(e =&gt; e.Name.LocalName == "ch").Select(n =&gt; n.Attribute("l").Value).ToArray(),
                                        VPOS = r.Descendants().Where(e =&gt; e.Name.LocalName == "ch").Select(n =&gt; n.Attribute("r").Value).ToArray(),
                                        chs = r.Descendants().Where(e =&gt; e.Name.LocalName == "ch").Select(n =&gt; n.Value).ToArray(),
  
                                    };
  
                  foreach (var item in coordinates)
                  {
                      alto.Append("&lt;String HPOS=\"" + item.HPOS.First() + "\" VPOS=\"" + item.VPOS.First() + "\" Width=\"" + (Double.Parse(item.VPOS.Last()) - Double.Parse(item.HPOS.First())) + "\" CONTENT=\"" + String.Join("", item.chs) + "\"/&gt;" + Environment.NewLine);
                  }
              }
              catch (Exception ex)
              {
                  Console.WriteLine("Message: " + ex.Message);
                  Console.WriteLine("Stacktrace: " + ex.StackTrace);
              }
              return alto.ToString();
          }
  </code></pre>
  
  <p>and here is the link of the sample <a href="http://pastebin.com/LmDHRzC5" rel="nofollow noreferrer">xml im converting</a></p>