Results 1 to 16 of 16

Thread: XPath Search Syntex {Resolved}

  1. #1

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Thumbs up XPath Search Syntex {Resolved}

    Hi

    Give the XML Schema provided here, how can I search for complexType where the name attribute's value is "OptTmsTimesheetEntry"

    I have this XPath Syntex but it's not working...???

    Code:
      FXmlSchema : IXmlDocument;
      aSelectNode : IDOMNodeSelect;
      aNode : IDOMNode;
      iRootNode: IXMlNode;
    
      FXmlSchema := LoadXMLDocument(XmlSchemaLocation);
    
      iRootNode := FXmlSchema.DocumentElement;
    
      aSelectNode := FXmlSchema.DOMDocument.documentElement as IDOMNodeSelect ;
    
      aNode := aSelectNode.selectNode('complexType[@name = "OptTmsTimesheetEntry"]');
    I also tried this...

    aNode := aSelectNode.selectNode('/xs:schema/xs:complexType/[@name = "OptTmsTimesheetEntry"]');

    Any suggestions...?
    Last edited by wrack; Nov 20th, 2003 at 08:05 PM.

  2. #2

  3. #3

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    Thank you martin but I am getting an error.

    "Reference to an undeclared prefix 'xsd' "

    what do u make out of it...?

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I'm not a schema expert, but the schema that that code assumes looks like this

    Code:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    	<xsd:element name="kb">
    		<xsd:annotation>
    			<xsd:documentation>Root element of each Pact Knowledge Base</xsd:documentation>
    		</xsd:annotation>
    		<xsd:complexType>
    			<xsd:sequence>
    				<xsd:element name="class" type="classType" minOccurs="0" maxOccurs="unbounded">
    					<xsd:annotation>
    						<xsd:documentation>A class represents a single PACT object</xsd:documentation>
    					</xsd:annotation>
    					<xsd:unique name="Attrib_Name_Unique">
    						<xsd:selector xpath="attrib"/>
    						<xsd:field xpath="@name"/>
    					</xsd:unique>
    				</xsd:element>
    				<xsd:element name="resource" type="resourceType" minOccurs="0" maxOccurs="unbounded"/>
    			</xsd:sequence>
    			<xsd:attribute name="kb-id" type="xsd:string" use="required"/>
    			<xsd:attribute name="kb-version" type="xsd:string" use="required"/>
    		</xsd:complexType>

  5. #5

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    Well my schema is same as urs but I have xs: instead of xsd: everything else is same.

    Am I using correct type of data types to declare variables...???

  6. #6

  7. #7

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    can you please tell me the type of XSDDOC variable you have declared...?

  8. #8

  9. #9

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    I think I am getting closer to solve this. Thank Matrin.

    more question.

    how do u load the schema into DOMDocument40 variable ...?

  10. #10

  11. #11

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    Cool thanks Martin.

    Now I am stuck in another problem. I suppose that you don't work with Delphi. Do you...?

  12. #12

  13. #13

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    No worries. Thanks for all ur input. I atleast came to right track. I was using wrong type of variables now I am using the correct one. Just a matter of figuring it out what I did wrong.


  14. #14

  15. #15

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    Access violation. That happens when some variable is set to nothing and I try to access it but in this case I am sure that it exists and I can see a pointer to it.

  16. #16

    Thread Starter
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695
    Originally posted by MartinLiss
    XSDDoc.Load strSchemaPathAndName
    DOH: DOH: DOH:

    I was using LoadXML method to load Schema and it was expecting schema file as a string not as it's location and name so all after that went to drain.

    I was so desperate to make it work that I missed what u said Martin. Thanks for all ur help.

    Cheers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width