|
suppose i have the folloing XML:
<bookstore>
<book>
<title> AAA</title>
<author> bbb</author>
<price> 40 </price>
</book>
</bookstore>
& i want "title" for example as a return element, at the same time it is the predicate element.. how to make this expression?
i tried:
//title[.='AAA']
& it didn't work?!
|
|
|
|
|
Hi!
try the following...
bookstore/book/title
It will return u the value - AAA
============================ A finite loop!
for (int i=0; i<=1; i++) if (i == 1) i = 0; ============================
|
|
|
|
|
Try //title[text()='AAA']?
|
|
|
|
|
Think Stuart is nearly correct, but it does not reach the correct depth.
/bookstore/book/title =>
So 3 '/' is needed if absolute paths are needed, or '.' in front if relative from /bookstore is required.
Absolute:
Relative from /bookstore:
.
-- modified at 21:39 Thursday 27th April, 2006
|
|
|
|
|
thank u all
i went with the last soloution,absolute didn't work
|
|
|
|
|
Graham N wrote:
/bookstore/book/title => ///title
Should be:
/*/*/title
Graham N wrote:
.//title[text()='AAA']
.//title All <title> elements one or more levels deep in the current context
//title Recursive descent; searches for <title> elements at any depth. When this path operator appears at the start of the pattern, it indicates recursive descent from the root node.
So, .//title only works when the current has <title> elements as descendants.
Thus, Stuart is correct and you are nearly correct.
-- modified at 23:37 Friday 28th April, 2006
|
|
|
|
|
Ah yes!
Now that would make more sense.
It's been a while since I've done any major XML projects.
|
|
|
|
|
Hi,
In order to display logdata stored in a single xml file in a pretty way I would like to use different xsl stylesheets transforming the xml file. Each XSL file extracts a certain aspect (system information, Process information)
I would like to create a html side having a coule of links on it. Each one of them should load a xml file with a different style sheet. While browing the usual newsgroups i found out that this should be possible using javascript but how? I would like to get more details on that, so can anyone point me in the right direction?
Thanks in advance
Ingo
|
|
|
|
|
Greetings all.
Is it possible to create a schema to enforce the following issue.
If the value for required Attribute A within Element E has an enumerated value of ‘myType’ then element E also needs to have Attribute B.
Xml example below
E=Item
A=type
B=len
<Items>
<Item type=” myType” len=”5” />
<Item type=” NOTmyType” />
</Items>
Any help or a point in a semi right direction would be very helpful
-- modified at 11:27 Tuesday 25th April, 2006
|
|
|
|
|
Not with XSD, IMO - you'd need something like Schematron[^]
|
|
|
|
|
was afraid of that.
thanks for the validation
is it then common practice to have different node names to start with, and not differentiate by node type?
|
|
|
|
|
Mmmmm - yes, I guess so. Otherwise you leave verification of semantic constraints (such as the one you want to enforce) to a stage *after* XSD validation.
|
|
|
|
|
i have to import inside a sql server 2005 table a file excel saved as an xml with a column with some strings.
column
-------
sfsdfsfd
dsfsfgg
54432fd
dss43r
gdgdgdfgd43
gdfgdfg43
etc...
how can i do?
|
|
|
|
|
how can i use / in the name of element, like < I / O > < / I / O >, i am using c# and it is throwing exception.
Shajeel
-- modified at 9:09 Monday 24th April, 2006
|
|
|
|
|
|
You can't. It goes against W3C's XML specifications.
|
|
|
|
|
i was looking at the following tutorial's last topic Element Naming.
http://www.w3schools.com/xml/xml_elements.asp
it doesn't say anything about this restriction.
Shajeel
|
|
|
|
|
Hi there.
Look at section 2.3 of the XML specifications[^]
Of particular interest are rules 4 and 5 which specifies the valid range of XML element names.
Quoting from the Specification:
Names and Tokens
[4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
[5] Name ::= (Letter | '_' | ':') (NameChar)*
[6] Names ::= Name (#x20 Name)*
[7] Nmtoken ::= (NameChar)+
[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*
Both IE and Firefox have XML support, so you could create an XML file containing the element and display the file in the software. It will perform a well-formed check on files with an .xml extension and will return any errors encountered.
Regards, Graham.
-- modified at 13:07 Tuesday 25th April, 2006
|
|
|
|
|
Thanks for the help.
Shajeel
|
|
|
|
|
Shajeel wrote: it doesn't say anything about this restriction.
Ha! Tricky isn't it...
(Taken from http://www.w3schools.com/xml/xml_elements.asp)
XML elements must follow these naming rules:
* Names can contain letters, numbers, and other characters
* Names must not start with a number or punctuation character
* Names must not start with the letters xml (or XML, or Xml, etc)
* Names cannot contain spaces
belive it or not, '/' (slash) is a punctuation character.
edit: oops, it says only at beginning. So they do miss this rule.
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
-- modified at 7:15 Wednesday 26th April, 2006
|
|
|
|
|
it is just saying names must not start with punctuation, i wasnt starting name with /, i want to just use it like < I / O > and first rule says it can contain other characters.
Shajeel
|
|
|
|
|
|
Hi. I'm using the xsd.exe utility to auto-generate C# classes for my .NET project from an XSD file. The "service" I am using does not have a WSDL, so generating proxy classes from wsdl.exe is not an option.
Does anyone have any experience using the auto-generated classes from xsd.exe? My problem is that in the XSD, I have a complex data entity that is of "type" such and such, and therefore, is not generated as it's own class.
The XSD defines a "complexType_decisionEngineRequest" like this:
<xs:complextype name="complexType_decisionEngineRequest">
<xs:complexcontent>
.
.
.
and later on, a "decisionEngineServiceRequest" element is defined of TYPE "complexType_decisionEngineRequest" like this:
<xs:element name="decisionEngineServiceRequest" type="complexType_decisionEngineRequest">
What xsd.exe ends up generating is a class for the "complexType_decisionEngineRequest", but not a class for the "decisionEngineServiceRequest", which is what I want for my XML base tag. I wish to declare these classes such that my XML that is serialized looks like this:
<decisionengineservicerequest>
....
My question is, is this a case where I should just give up and write my own class, or is there a way to do this with the auto-generated classes from xsd.exe?
Anyone have a similar experience?
|
|
|
|
|
Woops, guess I can't include the XML source!
try again...
Hi. I'm using the xsd.exe utility to auto-generate C# classes for my .NET project from an XSD file. The "service" I am using does not have a WSDL, so generating proxy classes from wsdl.exe is not an option.
Does anyone have any experience using the auto-generated classes from xsd.exe? My problem is that in the XSD, I have a complex data entity that is of "type" such and such, and therefore, is not generated as it's own class.
The XSD defines a "complexType_decisionEngineRequest" like this:
<xs:complexType name="complexType_decisionEngineRequest">
<xs:complexContent>
.
.
.
</xs:complexContent>
</xs:complextType>
and later on, a "decisionEngineServiceRequest" element is defined of TYPE "complexType_decisionEngineRequest" like this:
<xs:element name="decisionEngineServiceRequest" type="complexType_decisionEngineRequest" />
What xsd.exe ends up generating is a class for the "complexType_decisionEngineRequest", but not a class for the "decisionEngineServiceRequest", which is what I want for my XML base tag. I wish to declare these classes such that my XML that is serialized looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<decisionEngineServiceRequest>
....
</decisionEngineServiceRequest>
My question is, is this a case where I should just give up and write my own class, or is there a way to do this with the auto-generated classes from xsd.exe?
Anyone have a similar experience?
|
|
|
|
|
michaelhardeman wrote: Woops, guess I can't include the XML source!
You can, but you must check "Ignore HTML tags in this message (good for code snippets)".
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|