EDN Admin
Well-known member
Hi;
I am creating an XPathNavigator with a schema of:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; schema <span style="color:Red; xmlns:xsd<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema<span style="color:Black; " <span style="color:Red; xmlns:bks<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; urn:books<span style="color:Black; " <span style="color:Red; targetNamespace<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; urn:books<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; books<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; bks:BooksForm<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; complexType <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; BooksForm<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; sequence<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; book<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; bks:BookForm<span style="color:Black; " <span style="color:Red; minOccurs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; maxOccurs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; unbounded<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; sequence<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; complexType<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; complexType <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; BookForm<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; sequence<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; author<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; title<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; genre<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; price<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:float<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; publish_date<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:date<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; description<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; sequence<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; attribute <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; id<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; complexType<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; schema<span style="color:Blue; >
[/code]
and
<span style="font-family:Courier New xml of:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; catalog<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; book <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; bk101<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; author<span style="color:Blue; >Gambardella, Matthew<span style="color:Blue; </<span style="color:#A31515; author<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; title<span style="color:Blue; >XML Developers Guide<span style="color:Blue; </<span style="color:#A31515; title<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; genre<span style="color:Blue; >Computer<span style="color:Blue; </<span style="color:#A31515; genre<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; price<span style="color:Blue; >44.95<span style="color:Blue; </<span style="color:#A31515; price<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; publish_date<span style="color:Blue; >2000-10-01<span style="color:Blue; </<span style="color:#A31515; publish_date<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; description<span style="color:Blue; >An in-depth look at creating applications
with XML.<span style="color:Blue; </<span style="color:#A31515; description<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; book<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; book <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; bk102<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; author<span style="color:Blue; >Ralls, Kim<span style="color:Blue; </<span style="color:#A31515; author<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; title<span style="color:Blue; >Midnight Rain<span style="color:Blue; </<span style="color:#A31515; title<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; genre<span style="color:Blue; >Fantasy<span style="color:Blue; </<span style="color:#A31515; genre<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; price<span style="color:Blue; >5.95<span style="color:Blue; </<span style="color:#A31515; price<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; publish_date<span style="color:Blue; >2000-12-16<span style="color:Blue; </<span style="color:#A31515; publish_date<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; description<span style="color:Blue; >A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.<span style="color:Blue; </<span style="color:#A31515; description<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; book<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; catalog<span style="color:Blue; >
[/code]
When I do a SelectSingleNode("/catalog/book[1]/price") I get back a string.
I assume this is because the schema is defining namespaces and because I am not setting those nor placing the set prefix in my xpath, it does a select, which works, but as it doesnt match the schema theres no type conversion.
Is that true? And if so:
1. How do I interpret <span style="color:#ff0000 xmlns:bks<span style="color:#0000ff ="urn:books<span style="color:#0000ff "<span style="color:#ff0000 targetNamespace<span style="color:#0000ff ="urn:books<span style="color:#0000ff "
2. How do I pull this info from XmlSchema and/or XmlSchemaSet for each node to know what namespace that element/attribute is using?
thanks - dave <hr class="sig Very funny video - http://blogs.windwardreports.com/davidt/2010/02/reporting-as-a-metaphor.html
Whats your Metaphor?
View the full article
I am creating an XPathNavigator with a schema of:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; schema <span style="color:Red; xmlns:xsd<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema<span style="color:Black; " <span style="color:Red; xmlns:bks<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; urn:books<span style="color:Black; " <span style="color:Red; targetNamespace<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; urn:books<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; books<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; bks:BooksForm<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; complexType <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; BooksForm<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; sequence<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; book<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; bks:BookForm<span style="color:Black; " <span style="color:Red; minOccurs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 0<span style="color:Black; " <span style="color:Red; maxOccurs<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; unbounded<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; sequence<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; complexType<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; complexType <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; BookForm<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; sequence<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; author<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; title<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; genre<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; price<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:float<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; publish_date<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:date<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; element <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; description<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; sequence<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; attribute <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; id<span style="color:Black; " <span style="color:Red; type<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; xsd:string<span style="color:Black; "<span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; complexType<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; xsd<span style="color:Blue; :<span style="color:#A31515; schema<span style="color:Blue; >
[/code]
and
<span style="font-family:Courier New xml of:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; catalog<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; book <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; bk101<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; author<span style="color:Blue; >Gambardella, Matthew<span style="color:Blue; </<span style="color:#A31515; author<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; title<span style="color:Blue; >XML Developers Guide<span style="color:Blue; </<span style="color:#A31515; title<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; genre<span style="color:Blue; >Computer<span style="color:Blue; </<span style="color:#A31515; genre<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; price<span style="color:Blue; >44.95<span style="color:Blue; </<span style="color:#A31515; price<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; publish_date<span style="color:Blue; >2000-10-01<span style="color:Blue; </<span style="color:#A31515; publish_date<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; description<span style="color:Blue; >An in-depth look at creating applications
with XML.<span style="color:Blue; </<span style="color:#A31515; description<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; book<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; book <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; bk102<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; author<span style="color:Blue; >Ralls, Kim<span style="color:Blue; </<span style="color:#A31515; author<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; title<span style="color:Blue; >Midnight Rain<span style="color:Blue; </<span style="color:#A31515; title<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; genre<span style="color:Blue; >Fantasy<span style="color:Blue; </<span style="color:#A31515; genre<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; price<span style="color:Blue; >5.95<span style="color:Blue; </<span style="color:#A31515; price<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; publish_date<span style="color:Blue; >2000-12-16<span style="color:Blue; </<span style="color:#A31515; publish_date<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; description<span style="color:Blue; >A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.<span style="color:Blue; </<span style="color:#A31515; description<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; book<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; catalog<span style="color:Blue; >
[/code]
When I do a SelectSingleNode("/catalog/book[1]/price") I get back a string.
I assume this is because the schema is defining namespaces and because I am not setting those nor placing the set prefix in my xpath, it does a select, which works, but as it doesnt match the schema theres no type conversion.
Is that true? And if so:
1. How do I interpret <span style="color:#ff0000 xmlns:bks<span style="color:#0000ff ="urn:books<span style="color:#0000ff "<span style="color:#ff0000 targetNamespace<span style="color:#0000ff ="urn:books<span style="color:#0000ff "
2. How do I pull this info from XmlSchema and/or XmlSchemaSet for each node to know what namespace that element/attribute is using?
thanks - dave <hr class="sig Very funny video - http://blogs.windwardreports.com/davidt/2010/02/reporting-as-a-metaphor.html
Whats your Metaphor?
View the full article