Re: How to associate XML with XSD

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • liuhengyi@gmail.com

    Re: How to associate XML with XSD

    Hi,

    I also have a question when using VS 2008 to edit the xml file. In my
    xml file, I used schemaLocation attribute to specify the xsd. If I put
    the xsd in our internal sharepoint site such as:
    xsi:schemaLocat ion="someNs http://sharepoint/Test.xsd"

    VS2008 xml editor shows that "this schema referenced from this
    location in your document contains errors". However if I copy the xsd
    to the local folder, and use this:
    xsi:schemaLocat ion="someNs C:\Test.xsd"

    Then it works fine. Also the first method works in VS 2005. So is
    there anything changed in the VS 2008 xml editor?

    Thanks,
    Heng-yi


    On Apr 7, 10:03 pm, stch...@online. microsoft.com (Steven Cheng [MSFT])
    wrote:
    Hi Bob,
    >
    As for XML document/file and the XML schema(xsd) it rely on(conform to),
    here are some of my understanding:
    >
    ** From XML standard, we generally do not specify the location (url or file
    path ) of the xml schema, we only add namespace attributes in XML document
    so as to indicate what namespace those Nodes in XML document belong to.  
    >
    ** For the location where to find the schema, it is normally the XML
    Editor/Designer's task. Yes, there is "xsi:schemaLoca tion" attribute that
    can help specify a schema via url/path location, however,  this is still
    depend on whether the XML Editor or designer will use it. If the IDE won't
    take care of this attribute(will try locating the schema from the specified
    location and perform validation).
    >
    ** For Visual Studio, it use several means to find the schemas to validate
    the document or provide intellisense:
    >
    1) schema in  the Visual Studio's global cache location. e.g. the VS 2008
    use the following path:
    >
    C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas
    >
    2) You can also add schema in the property window when you editing a xml
    file in VisualStudio xml editor
    >
    3) Visual studio xml editor will also look for "schemaLocation " you
    specified in xml document for reference
    >
    You can also add your own schemas to global cache or customize it. The
    following MSDN documenet has mentioned those features:
    >
    #Schema Cache  http://msdn2.microsoft.com/en-us/lib...21(VS.80).aspx
    >
    Hope this helps.
    >
    Sincerely,
    >
    Steven Cheng
    >
    Microsoft MSDN Online Support Lead
    >
    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msd...@microsof t.com.
    >
    =============== =============== =============== =====
    Get notification to my posts through email? Please refer tohttp://msdn.microsoft. com/subscriptions/managednewsgrou ps/default.asp...
    ications.
    >
    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) athttp://msdn.microsoft. com/subscriptions/support/default.aspx.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights..
    >
    --------------------
    >
    >
    >
    >
    >
    From: "Bob Altman" <r...@nospam.no spam>
    References: <uVZqyNQmIHA.3. ..@TK2MSFTNGP02 .phx.gbl>
    Subject: Re: How to associate XML with XSD
    Date: Mon, 7 Apr 2008 16:54:40 -0700
    I think I found most of my answers myself.  (Actually, a coworker happened
    to
    wander by my padded cell and he enlightened me ;-)  I'd appreciate if
    someone
    who actually knows this stuff would comment on this posting to let me know
    if
    I've got this more or less correct.  Thanks!
    >
    1. Assuming that I have an XML file and its associated XSD file, what do
    I put
    into the XML file to tell Visual Studio to use the XSD file to wire up
    intellisense?
    >
    My coworker showed me how to include a bunch of xmlns gibberish in the
    top-level
    element to specify the schema location:
    >
    <TopLevelElemen t
     xmlns="MyDefaul tNamespace"
     xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
     xsi:schemaLocat ion="MyDefaultN amespace MySchemaFile.xs d" >
    >
    In the above example, "MyDefaultNames pace" is usually a string that looks
    like a
    web URL, but it can pretty much be any string that doesn't include
    whitespace or
    escaped characters.
    >
    2. Is there something else that I need to (or should) do to tell the VS
    IDE
    that my XML file has an associated XSD file?
    >
    The "properties " for the XML file includes a field that specifies the
    related
    XSD file.  I don't know what happens if this property conflicts with the
    above
    XML text.
    >
    The existence of this property solves another mystery -- how the IDE knows
    about
    the schema of app.config files even though the text of the app.config file
    doesn't contain any obvious reference to a schema file.- Hide quoted text-
    >
    - Show quoted text -
Working...