[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

xpath path

in this example:

http://msdn.microsoft.com/en-us/library/5z124f36%28VS.71%29.aspx
<xs:key name="OrderNumberKey"  >
    <xs:selector xpath=".//Order" />
    <xs:field xpath="OrderNumber" />
  </xs:key>

what is this path?
".//Order"

if my schema is in:
app_code/schemas/

what does it represent? as far as .//Order?

Is there a webform named Order somewhere?

Please be specific. I know nothing about this.

thanks.
0
Starr Duskk
Asked:
Starr Duskk
  • 6
  • 4
1 Solution
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I just tried to add a schema to my app_code directory and noticed it doesn't allow it as an option.
So I moved my code out to the /Schemas directory from the root.
 
0
 
Geert BormansCommented:
The above Schema Snippet expresses a uniqueness constraint

It says that all Order elements anywhere in the MyDataSet require to have a unique OrderNumber
I you don't need that, you can remove the xs:key elements
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I asked a specific question about the xpath.
 
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Geert BormansCommented:
sorry, your question was a bit confusing

".//Order"
means
The Order element at any depth starting from the current context
it is equal to
"descendant::Order"

it is not equal to "//Order", since that one starts from the root, not from the current context

hope this helps
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Sorry, no it doesn't help.
Please give me an example of what that means.
I told you I don't understand any of this.
the order in relation to what? current context of what?
 
 
 
 
0
 
Geert BormansCommented:
In your schema you have an <Order> element declared

...
<xs:element name="Order">
...

This <Order> is declared inside a choice inside a <MyDataSet> element

The key is a uniqueness constraint, defined in the context or scope of MyDataSet

I now give you an example XML, that goes with your schema
<SomeRoot>
<MyDataSet>
   <Order>
        <OrderNumber>1</OrderNumber>
        <EmpNumber>1</EmpNumber>
   </Order>
   <Order>
        <OrderNumber>2</OrderNumber>
        <EmpNumber>1</EmpNumber>
   </Order>
   <Order>
        <OrderNumber>3</OrderNumber>
        <EmpNumber>1</EmpNumber>
   </Order>
</MyDataSet>
   <Order>
        <OrderNumber>1</OrderNumber>
        <EmpNumber>2</EmpNumber>
   </Order>
</SomeRoot>

In the context of MyDataSet there are three Order elements (descendants of the MyDataSet) (.//Order)
In the context of the full document there are four Order elements (//Order)
According to the key constraint they should all three have a different OrderNumber, so the above is valid , the fourth one is not taken into account (out of scope)
Note that in my Example MyRoot is not declared in your sample schema, I made it up for the sake of the example
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
thanks!
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
thanks! that helped a lot!
 
0
 
Geert BormansCommented:
welcome
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now