468,769 Members | 2,306 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,769 developers. It's quick & easy.

Re: How to associate XML with XSD


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:schemaLocation="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:schemaLocation="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?

On Apr 7, 10:03*pm, stch...@online.microsoft.com (Steven Cheng [MSFT])
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:schemaLocation" 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.


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:

Get notification to my posts through email? Please refer tohttp://msdn.microsoft.com/subscriptions/managednewsgroups/default.asp...

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.nospam>
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
wander by my padded cell and he enlightened me ;-) *I'd appreciate if
who actually knows this stuff would comment on this posting to let me know
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
My coworker showed me how to include a bunch of xmlns gibberish in the
element to specify the schema location:
*xsi:schemaLocation="MyDefaultNamespace MySchemaFile.xsd" >
In the above example, "MyDefaultNamespace" 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
that my XML file has an associated XSD file?
The "properties" for the XML file includes a field that specifies the
XSD file. *I don't know what happens if this property conflicts with the
XML text.
The existence of this property solves another mystery -- how the IDE knows
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 -
Jun 27 '08 #1
0 2992

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by knutsample | last post: by
6 posts views Thread by Ashok | last post: by
2 posts views Thread by Angel | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.