Dear smart person,

Okay, I'm on a Win2k box with SQL 2000 and i want to start using XPath.  Here is the purpose:

I users on my site, and i want them to access their profiles by:

From what I've understood so far, I have created a Virtual Directory in SQLXML called Users and enabled XPath.  What do I do from there?

I know this question is really indescript, but I can't think of a better way to put it, so I left it as this and put it as 500 pts

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You'll also need to create an annotated schema, that tells SQL XML what your XML needs to look like, and relates the elements to the tables and columns of your DB.  This used to be known as "XML View" but now is known as an annotated mapping schema.  For example, here's an XDR Schema for the Northwind Customers table:

<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"

  <ElementType name="Customer" sql:relation="Customers" >
    <AttributeType name="CustomerID" />
    <AttributeType name="ContactName" />
    <AttributeType name="Phone" />

    <attribute type="CustomerID" />
    <attribute type="ContactName" />
    <attribute type="Phone" />

You might put this XDR schema the schema subdirectory of the virtual root directory, and call it SchemaCustomers.xdr.

An XPath query against the annotated schema can be specified directly in the URL:


Or you can specify it in a template:

<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
  <sql:xpath-query mapping-schema="schema/SchemaCustomers.xdr">

The mapping schema file path is relative the virtual root, not the location of the template.

Mike Sharp

BeamerColaAuthor Commented:
Man, you're on top of this.  I love you.

Okay, tell me if i did this right.

Copied your Schema stuff, and put it in a file called Users.xdr in my XML folder

I then opened IIS Virtual directory Manager for SQL Server and opened the properties for my virtual directory "Users" underneath my server.  on Virtual Names I put one named "Users" as a Schema type and pointed it to the xdr file.

What happens from there to be able to access information by

Also, is it possible to run ASP scripts in there? or will it be strictly XML?

Thanks so much
The Schema virtual name should point to a folder, which contains the users.xdr.

It would then be something like:


And don't put anything else like ASP in those folders.  Well, I've put XSLT in there...

Mike Sharp
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

BeamerColaAuthor Commented:
Okay this is starting to make more sense.

now how do i get it to read an XML file to show that information?

and will you have to type in users/users.xdr/username?  how would you get it where its pretty, and just says
server.com/users/username/ ?

Thanks so much for all your help, i'd increase the points, but i cant.
BeamerColaAuthor Commented:
oh i think i'm seeing that its supposed to be pulling from the database?  heres my xdr file

<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"

  <ElementType name="User" sql:relation="tbl_Users" >
      <AttributeType name="UserID" />
      <AttributeType name="UserName" />
      <attribute type="UserID" />
      <attribute type="UserName" />

tbl_Users is the table with UserID and UserName in it..
That looks good...If I recall correctly, as long as your attribute names are the same as the column names in the table, you don't have to map the attribute to the column.  But if you wanted to change the name of your UserID column in the DB to BloggerID in the XML (for example) you can annotate the attribute type to define the mapping.

As I mentioned before, you can get the XML either by loading the "URL" of the schema, and passing an XPath expression on the URL, or you can put the XPath in a template and use that.  The template approach is a little more secure, in that you can control the XPath's that the user can use.

Mike Sharp
BeamerColaAuthor Commented:
When I go to


i get
HResult: 0x80040e14
Source: Microsoft XML Extensions to SQL Server
Description: MSXML3: is an invalid or unsupported XPath
i think i'm confused on what's supposed to happen.  is XPath what I'm looking for?  I bought an XQuery book today to start learning about that, i'm now confused on both.

I want to be able to go to
and it pull up my profile, formatting it with CSS


Users is a virtual name of type Schema, right?  It is a child of your virtual root?  That is, you have a virtual root that is configured using SQL XML to be:


and then you add a schema type below it, like:


and in the users schema directory is the schema you create, users.xdr.

So you should use a path like:

www.server.com/vroot/users/users.xdr/User[@UserID = 'BeamerCola']

Mike Sharp

BeamerColaAuthor Commented:
i have Users as a Virtual Directory, and in the Virtual Names tab, i've set up Users as a Schema pointing to Users.xdr

is it possible to not use a root?

And do you always have to specify users.xdr, and [@UserID = 'BeamerCola'] ?
I'm not sure if it works with the schema virtual name pointing to the same directory as the vroot.  

As far as the XPath, well, that's how XPath works.  You probably want to use a template like I showed you in the earlier post.  Then you'd use something more conventional like:


Mike Sharp

BeamerColaAuthor Commented:
Maybe XPath is not what I'm looking for.  Pretty much the only reason i'm implementing this is for ease-of-use for the users by being able to go to "www.server.com/users/beamercola/" to access their information.  The quick explanation in SQLXML showed XPath as the thing for that.

if XPath isn't that, then what would i be looking for?

Well, that something you get with some application servers.  For example, my site, http://dev.rdcpro.com has a system of parsing the URL, so that each "part" of the URL is separate.  So, my member pages are located at:


and my own particular page is:


But when I log in, no matter where I am in the site I can always click the link on the horizontal nav bar that takes me to a page where I set my preferences.  Because I'm logged in, it knows who I am.  You don't need a separate page for each user, you need a single page, so that authenticated users can see their information.  What's to stop someone from entering another user's URL?  Really, what you're wanting is a page that will take the user id from the session variable (where they logged in), and query the DB and get the appropriate User data which is rendered in the page.  

Mike Sharp

BeamerColaAuthor Commented:
It's a public site, so I want people to be able to type in other peoples usernames.  I'm also going to be implementing this into a news site i'm working on, which will work like:


and that would pull up article 001.  so it would skim through the XML document to Articles, then inside that find 2003, then january, and then 001.
This is a very common approach for some application servers, but not really for IIS, at least as far as I know.  I think you'll have to write an ISAPI filter that does the parsing of the URL to extract the query information, and map it to the appropriate resources.  And that sounds like a lot of work.  It's easier to use query strings, as I mentioned earlier.  However, if you really must have that type of query, you might consider other platforms, such as Zope, which does this very well.  It can run on Windows, behind IIS, but also comes with it's own web server (Medusa).  ISPs usually run it behind Apache.  Zope is programmed in Python, though, and it means you'll probably have to learn a new language.  But, it's a very elegant OO language, and worth learning.  And, as a bonus, your RSS is built-in, along with XML-RPC and a whole raft of other cool stuff.  

But the best part is that it's free, and has a pretty talented community behind it.  The only drawback is that there aren't many ISPs who specialize in it, and although you could manage it yourself, it's nice to have a host that understands the issues.  If you self host (through a local DSL connection or something), then it's worth trying out anyway, because it will work fine out of the box responding to port 8080 by default. So it can co-exist peacefully with your existing site.

Mike Sharp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BeamerColaAuthor Commented:
Thanks for all your help,

Do you know what that kind of approach is called?  So i could look around to see the possibilities in IIS?

I guess I'm a little confused, when I look in the IIS Virtual Directory Management for SQL in the Settings tab, it shows for the XPath example as:

Allows users to execute XPath queries over SQL Views provided by mapping schemas.

how would that be different from

Thanks so much for your help.
Right, but the XPath "CustomerList" essentially returns a nodelist containing the nodes for all customers.  If you want  a particular customer, you have to use a predicate like:

http://server/virtualdirectory/cust/CustomerList[@custID = 'ALFKI']

I can't recall the term for that URL approach...but it's fairly common.

Mike Sharp

BeamerColaAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.