How do you acces secondary datasources - InfoPath Dev
in

InfoPath Dev

How do you acces secondary datasources

Last post 01-16-2006 09:07 AM by Matt Faus. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-13-2006 07:19 AM

    • Thomas
    • Not Ranked
    • Joined on 01-10-2006
    • Denmark
    • Posts 2

    How do you acces secondary datasources

    Hi there - I am trying to create a "print view" using the recipe provided in Matts article.

    I have a template whoose layout is already governed by an XML Schema definition (Schema1). Following the steps in the article I create an extra sample XML document whoose structure follows the structure required by the print view. I import this document as a secondary datasource and have the print view use it. Infopath itself is creating a schema for this (Schema2).

    So far so good.

    The task is now - when the print view is selected - to transform the data loaded (following Schema1) to a structure that fits the schema for the print view (Schema2) and put it into the secondary datasource used by the print view.

    However, I cannot figure out how to access the DOM of the data underlying the print view. The DOM property of XDocument contains the DOM tree for the main data (schema1).

    Does anyone know what I am doing wrong?

    Cheers
    Thomas
  • 01-13-2006 08:44 AM In reply to

    Re: How do you acces secondary datasources

    Glad to hear the article is helping you out! Making those print views can be a monstrous task sometimes.

    To access the DOM of the secondary data source you should be able to use a command like this:

    XDocument.GetDOM( "NAME OF SECONDARY DATA SOURCE" );

    This is in the code in the article about 13 lines down. You'll just have to modify it to match your schema. Let us know if you have any more problems! Good luck!

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-16-2006 05:48 AM In reply to

    • Thomas
    • Not Ranked
    • Joined on 01-10-2006
    • Denmark
    • Posts 2

    Re: How do you acces secondary datasources

    Hi Matt - thanks for the help, it worked.

    I did notice that line of code you mention, but I did not connect the "Vehicles" string in the code with name of the secondary data source. Also, the XDocument.GetDOM(...) only seems to work for secondary data sources. I tried it with "Main" and it returned null. To get the data source for the loaded document you have to use the XDocument.DOM property.

    Another thing which has tricked me is the namespace issues when making lookups. My XPath queries into the DOMs did not work until I added a namespace prefix to the queries like this:

    // Source nodes
    var srcLines = domSrc.selectNodes("/src:Summary/src:line");

    The code above only works if the start of the script contains the following namespace definitions. I left out some of the namespaces for brevity:

    //<namespacesDefinition>
    XDocument.DOM.setProperty("SelectionNamespaces",'... xmlns:src="schema1" ... ');
    XDocument.GetDOM("PrintSummary").setProperty("SelectionNamespaces", ' ... xmlns:dest="schema2" ... ');
    //</namespacesDefinition>

    The DOM for my secondary data source is accessed by the name "PrintSummary".

    If you guys have the time I think an article concerning the subject above would help a lot of people.

    Thanks again for the tip.

    Thomas
  • 01-16-2006 09:07 AM In reply to

    Re: How do you acces secondary datasources

    No problem, glad you got things working. I'll talk to the team about a HowTo concerning namespaces. There are several already on the web and the W3C has a great tutorial regarding this matter. However, it is not specific to InfoPath.

    http://www.w3schools.com/xml/xml_namespaces.asp

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.