in

The ORM Foundation

Get the facts!

Names with Spaces in the generated XSD

Last post 05-06-2009 16:28 by Orion Buhler. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-27-2009 15:33

    Names with Spaces in the generated XSD

     I've found that when I turn on the extension to generate XSD from the conceptual model, the result failthfully carries over the spaces in the names of the objects from my diagram, which invalidates the XML.  So far, I have not had any luck editing the OIALtoXSD.xslt transform file to include a function to replace the spaces in the name with an underscore.

     

    Has anyone else run into this same issue with the resulting XSD?  Is there another solution beyond just including the underscores in my ORM diagram names in the first place?

  • 04-30-2009 12:46 In reply to

    Re: Names with Spaces in the generated XSD

    Orion, 

    There has been basically no work done on this file in ages. I would consider it more a 'proof of concept' than a finished product. However, changing it to scrub names should not be overly difficult if you need a schema file generated.

    1. Look for the {@name} uses in the transform file. They will all be in xsOut: tags. There may be a couple of other names used other ways (parentName), but they all come from @name attributes.
    2. Decorate these with a function. The easiest call is to simply remove the spaces, giving you {translate(@name,' ', '')}
    3. If you want to get more robust, try using an extension function like the following to allow {fn:EncodeLocalName(@name)}, or a combination like {fn:EncodeLocalName(translate(@name,' ', '_'))}

     <msxsl:script implements-prefix="fn" language="CSharp">
      <![CDATA[
      public static string EncodeLocalName(string value)
      {
       return System.Xml.XmlConvert.EncodeLocalName(value);
      }
      ]]>
     </msxsl:script>

    The 'fn' prefix can be bound to any namespace you like on the root element (xmlns:fn="local:functions"), and should be listed in the extension-element-prefixes list on the first element.

    Let me know if you can get it working.

    -Matt

  • 05-06-2009 16:28 In reply to

    Re: Names with Spaces in the generated XSD

     Thanks again,Matt.  I added the 'translate' bit to the appropriate xs:out tags, and it worked.

     

    I had a bit of trouble before I realized that the generator settings dialog was not checked for XSD - that was why my changes weren't showing up.

     

    Any notion as to when this generated schema might reflect the recently added Grouping information?

Page 1 of 1 (3 items)
© 2008-2014 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service