Help! - InfoPath Dev
in

InfoPath Dev

Help!

Last post 10-25-2004 07:57 AM by jonbrave. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 10-15-2004 12:48 PM

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59

    Help!

    OK, I'm trying here to see whether I can get any response to InfoPath questions. I have tried in the MS newsgroup, and just don't seem to get anywhere. Is anyone here? I think it will take Greg to answer --- please help! I'm tearing my hair out over InfoPath questions...

    First question: can I get at the XML schema programatically? I may not be understanding the basics of XML document stuff, I'm not sure.

    I can see the DOM shows the contents of the XML of my form. I am using a web service returning a dataset, and I can see that an XSD is being generated and included in my IP project. I can see that IP is using this to decide how to deal with my fields, e.g. optional etc. What I don't get is I cannot find any way of getting at that information from script (since I am not typing in the XSD myself, I can't modify that). I have looked at everything from the XDocument, the DOM and so on with no luck. Am I supposed to be able to get at it in any way?

    Please answer. Anything will do! Even a "don't know" shows someone is there. If we get anywhere in this forum, I have plenty other questions!
  • 10-15-2004 03:06 PM In reply to

    I'm not sure what you had in mind for wanting to access the schema directly, but it is possible.

    You will be working with a local copy of the schema and so any changes you make will not be affecting your form... but this is a good thing as changing your schema live would likely have disasterous results.

    Here's the code to get access to you schema file. One you have it loaded you can access it just as you would any other DOM.

    oMySchema = new ActiveXObject("msxml2.DOMDocument.3.0");
    oMySchema.async = false;
    oMySchema.load("mySchema.xsd");

    Hope that helps! Let me know how it goes. Again, I'd love to hear what you had in mind for this...


    Greg Collins [InfoPath MVP]
  • 10-19-2004 01:51 PM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59
    OK, we're cookin' here! Looks like I might get some replies here :)

    I'm supposed to be on holiday in USA at present, so I'll wait till I get back for other questions.

    For this one, what I had been intending was to be able to make minor alteration to schema at runtime. I might be getting hold of wrong end of stick, but I don't think so. My schema is being auto-generated from a webservice returning a dataset, so I don't have much control over it, right? I quite wanted to add "minLength="1"" in to make some fields compulsory. Also, I wanted to try to have "nillable="true"" instead opf minOccurs=0 --- this is all to do with compulsory versus required...

    The question is: are you saying I can only have read access to schema at runtime? I want to actually change the behaviour of IP, though not save schema back permanently. Also, I don't quite understand your reply (haven't tried it yet, I'm on holiday :) ), you're loading the XSD by filename, but I haven't got the file, have I, I've just got the XSN with it buried inside?

    I know this reply is a bit confused. But I sense someone who wants to answer questions about his baby!
  • 10-20-2004 08:49 AM In reply to

    If you have your Web service established as a Data Connection, then the schema has already been created and is part of the .xsn file. If you extract the form files (See the File menu in the designer), then you can see what .xsd files are in your template.

    Again, if you have the Web service as a Data Connection, then the schema is present and you can modify it. This would give you everything you need, assuming your requirements are not constantly changing at runtime.

    I don't expect you will be able to dynamically modify the schema, though someone may wish to prove me wrong.

    Greg Collins [InfoPath MVP]
  • 10-23-2004 09:56 AM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59
    OK, let's see if I understand this right now.

    I have a webservice. It returns an ADO.NET dataset. IP gets/generates the schema for this at design time, storing it as an XSD effectively embedded in the XSN.

    I fancy getting a bit more control over the schema. Let's say, I want one or both of:
    * restriction minLength="1", to make a string show as compulsory
    * change a minOccurs="0" to a nillable="true"

    I thought I could do this at runtime, e.g. by getting at and altering the schema def after IP had read it in. I don't see how it could do this (easily) by altering the schema generated from the dataset, as I don't seem to have much control over that.

    But you're saying the only way I could do that is by actually altering the contents of the embedded XSD before it gets read in, right? This is doubly difficult for me as in practice my dataset columns vary at customers' sites (they add their own columns), I was planning to supply a "framework" XSN and tell them to reconnect & regenerate it when they change columns; I don't want them to have to do much work. I/they would have to:
    * unpack the XSD from the XSN
    * read, alter, write back the XSD
    * then (maybe) repack the XSD into the XSN

    Right?

    If so, that's too difficult, I think. I guess I'll just have to give up on trying to add in these two restrictions.

    Or to put it another way, would you say that trying to introduce "minLength" and/or "nillable" into a dataset-generated web service is a no-no? It might be OK if you're hand-rolling the XSD, but not for my case?

    Different questions to come next week... :)
  • 10-23-2004 11:28 AM In reply to

    Maybe data sets are different. I've never used them before. For a standard data connection the schema for that data connection is only created when you create the data connection. It is a fixed .xsd file in your .xsn (which you can extract and modify).

    If data sets get dynamic schemas then I'm not sure how that works. You did have another answer from the public newsgroups that may help you. I've copied the text here below:

    quote:
    You just have to extract the Schema from the DataSet, make your modifaction and load it back to the dataset.Look around XmlDataDocument and the solution is just there!

    I hope this helps...

    Greg Collins [InfoPath MVP]
  • 10-25-2004 07:57 AM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59
    Thanks. I hadn't seen that reply. I'll look into it.
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.