Jump to content

dooberry

Members
  • Posts

    133
  • Joined

  • Last visited

Everything posted by dooberry

  1. Woohoo!!!!!I've included the following link because it's just solved the problem:treasure trove of infoI've also included the stylesheet code (but not the xml file because it's confidential) so that other people can use this.I've not finished it yet, though because the Select control in the code doesn't submit a value at present (but I'll soon change that!!).Here you go: <?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="Quote"><html><script type="text/vbscript"> Sub submitrecord Dim xmldoc, updatednode, rootel set xmldoc=CreateObject("Microsoft.XMLDOM") xmldoc.async="false" xmldoc.load "quotecontact.xml" set rootel = xmldoc.documentelement set updatednode = rootel.selectsinglenode("contact") updatednode.text = document.getelementbyid("contact").value set updatednode = nothing set updatednode = rootel.selectsinglenode("ASM") updatednode.text = document.getelementbyid("manager").value set updatednode = nothing set updatednode = rootel.selectsinglenode("companyname") updatednode.text = document.getelementbyid("company").value set updatednode = nothing set updatednode = rootel.selectsinglenode("address1") updatednode.text = document.getelementbyid("companyaddress1").value set updatednode = nothing set updatednode = rootel.selectsinglenode("address2") updatednode.text = document.getelementbyid("companyaddress2").value set updatednode = nothing set updatednode = rootel.selectsinglenode("address3") updatednode.text = document.getelementbyid("companyaddress3").value set updatednode = nothing set updatednode = rootel.selectsinglenode("town") updatednode.text = document.getelementbyid("companytown").value set updatednode = nothing xmldoc.save "quotecontact.xml" set updatednode = nothing set rootel = nothing set xmldoc = nothing End Sub Sub cancelrecord msgbox "you clicked Cancel" End Sub</script><body><select id="manager"><xsl:for-each select="document('ASMS.xml')//ASMS/ASM"> <option> <xsl:attribute name="value" > <xsl:value-of select="areacode" /> </xsl:attribute> <xsl:value-of select="ASMname" /> </option></xsl:for-each></select><xsl:apply-templates select="contact" /><xsl:apply-templates select="companyname" /><xsl:apply-templates select="address1" /><xsl:apply-templates select="address2" /><xsl:apply-templates select="address3" /><xsl:apply-templates select="town" /><input type="button" id="dealdefnext" onclick="submitrecord" value="Next>>"/><input type="button" id="cancel" onclick="cancelrecord" value="<<Cancel"/></body></html></xsl:template><xsl:template match="contact"><table width="100%" border="0" padding="2"><tr><td width="20%">Contact:</td><td> <input type="text" id="contact" maxlength="50"><xsl:attribute name="value"> <xsl:value-of select="." /></xsl:attribute></input></td></tr></table></xsl:template><xsl:template match="companyname"><table width="100%" border="0" padding="2"><tr><td width="20%"> Company:</td><td> <input type="text" id="company" maxlength="50"> <xsl:attribute name="value"> <xsl:value-of select="." /> </xsl:attribute> </input></td></tr></table></xsl:template><xsl:template match="address1"><table width="100%" border="0" padding="2"><tr><td width="20%"> Address:</td><td> <input type="text" id="companyaddress1" maxlength="50"> <xsl:attribute name="value"> <xsl:value-of select="." /> </xsl:attribute> </input></td></tr></table></xsl:template><xsl:template match="address2"><table width="100%" border="0" padding="2"><tr><td width="20%" /><td> <input type="text" id="companyaddress2" maxlength="50"> <xsl:attribute name="value"> <xsl:value-of select="." /> </xsl:attribute> </input></td></tr></table></xsl:template><xsl:template match="address3"><table width="100%" border="0" padding="2"><tr><td width="20%" /><td> <input type="text" id="companyaddress3" maxlength="50"> <xsl:attribute name="value"> <xsl:value-of select="." /> </xsl:attribute> </input></td></tr></table></xsl:template><xsl:template match="town"><table width="100%" border="0" padding="2"><tr><td width="20%" /><td> <input type="text" id="companytown" maxlength="50"> <xsl:attribute name="value"> <xsl:value-of select="." /> </xsl:attribute> </input></td></tr></table></xsl:template></xsl:stylesheet> Well done akaii!!
  2. Ok,Boen_ I looked at some of your other posts to see if they would give me any ideas and I came up with the following -Let's say I use <xsl:variable> to define a variable which will refer to an xml file (have you guessed what it is yet?) - Can I then change the file my variable contains so that I can transform different documents to create the layout I require?If so how do I get the variable to contain a whole xml structure?Dooberry pie and warm custard .
  3. dooberry

    call-template

    I think it's supposed to be <apply-templates select="t1" /> rather than using call-template.If you use it this way, then you can define three templates for the same element within your xsl document and use choose to apply the appropriate template.Alternatively, you could put the criteria within the template so that it formats differently for different properties of your root element, I don't know if one is better than the other, because you probably have to write the same amount of code for both.Then you can base your template on <xsl:template match="insert element name here" /> and you don't have to worry about when the formatting will be applied.I hope this helps, but if not then I apologise.Dooberry is still in the top ten on Yetisports.
  4. Ok I think I've found out how to express the nature of the problem clearly.It's a similar idea to frames. If I create frames on a page, each with their own source page, can the page which contains the frames reference the objects in each frame?For example: <html><script language="vbscript"> dim object1 object1=document.getelementbyname("frame1contentobject1") msgbox "you entered " & object1.value</script><frameset rows="80%,20%"> <frame name="frame1" src="frame1content.htm" /> <frame name="frame2" src="frame2content.htm" /></frameset></html> If anyone can help with this it would be most useful.Dooberry Pie.
  5. I can see where you're coming from, but unfortunately I am writing entirely on the client side, the idea is the client will create xml files on the client side from the html form and the data from these will be posted through ADO to the server.I'm having trouble trying to get the select element to work.I've got a data island to populate text input elements without a problem, but I want the options in the select element to read from a separate xml data island.This is easy with an xsl sheet: <select id="selectid"><xsl:for-each select="optionfield"> <option> <xsl:attribute name="value"> <xsl:value-of select="fieldvalue" /> </xsl:attribute> <xsl:attribute name="selected"> <xsl:value-of select="optionselected" /> </xsl:attribute> </option></xsl:for-each></select> but the problem arises when I want the options for the select element to be stored outside the xml output. Using script to do this is easy, because I can use document.write to transform as many xml documents on one page as I like (this is a useful feature for later in the process), but I would like to avoid the script, if at all possible, for re-usability.Is there a way I can get round this using multiple data islands?If there is, can someone help me with the code please?
  6. Took some figuring out.I'm disappointed that you can't bind use the datasrc object in a form and you can only use it in a table. It'll all be much better when XFORMS get switched on and there'll be much less messing about with scripts.For the time being, this could be ideal, I can have 2 data islands and I can bind the select element to one of the fields in the alternative data source.This means I don't have to change the form to update lists - Woohooo!!!!.The only thing is that I'll have to use XMLDOM to update the xml file with the changes to the input fields.I'll post the code when I've finished for other beginner developers. Dooberry
  7. dooberry

    Frames

    Ok I can see where you're coming from and it's as I suspected.If I look at using the <div> tag, that might do the job (table is good, but there are too many tags to audit for this exercise).Thanks for your help.Dooberry P.S. How come it takes so long to get a response in the XSL forum, when you can get a response here this quickly?
  8. dooberry

    Frames

    I'm trying to use frames in an html page, but I'm running into problems.Is there a way I can control the content of a frame by using html within the frame opening and closing tags instead of using the src attribute?for example:<code><frameset rows="25%, 50%, 25%"> <frame id="headerframe"> <some html here as a header block> </frame> <frame id="bodyframe"> <some html here as the main body (actually a form)> </frame> <frame id="navigateframe"> <input type="button" value="<<Back " onclick="goback" id="previous"/> <input type="button" value="Next >>" onclick="goforward" id="next" /> </frame></frameset</code>I'm trying to do this to make sure that I can reference the controls in some script I am using to submit data through ADO, but it doesn't work (I can't see the frames and the page appears to be continuous). What I am worried about is that if I use the src attribute I will lose the reference to the document's input elements. If anyone can help I'd greatly appreciate it.Dooberry
  9. I know what you mean, I think the problem is that most of the people are too busy dealing with professional websites to help so don't judge too harshly.Looking at your post, there might be something you can do using xsl:for-each.You could create a variable which you update inside the xsl:for-each statement (in this case xsl:for-each select="table"). I'm still quite new to xsl so don't blame me if it doesn't work, but I think I've replied to more posts in here than a lot of people (including most of my own).In the meantime, calm down and have a nice cup of tea and some scones while you figure out how to do it.Sorry I couldn't be more help.Dooberry
  10. Ok I think I can see a way this might work.If I plug an invisible frame into the document, it can read a different source page to the rest of the document and I can change the nodes using vbscript.If I get this working I'll post the code for other people to look at.Dooberry
  11. Guys,I've not tried to do it yet so don't mock me.. Is it possible to use an xml document as a list of options for a drop down box that is separate from the document which stores the data?I would like to be able to update the options discreetly from the xsl template to save having to re-write the whole document (or even sections of it).I guess I was wondering if an xsl template can transform separate xml documents at the same time (is this what namespaces are for?).Any advice would be appreciated (if there was a begging bowl smilie I'd use it right here!!).Dooberry.
  12. I've been handed some research on this topic and it's something I'd never even heard of (being quite new to all this web development malarkey). Apparently, htm files do not have access to a client but hta files do. I changed the suffix of the file and it all works beautifully.It would be useful to cover stuff like this in the tutorials, something about explaining what different file types do in html applications?If this is already covered, can someone tell me where please?Dooberry.
  13. Ok, this is a real pig!The problem is not with the file. I've created the document from scratch and appended an element to the document by reading the html form.When explorer gets to the line to save the document as a new file, it still says 'xmldoc.save: Access Denied'.Has anyone else encountered this?Is this an issue with VBScript that doesn't apply with JavaScript?Is this a browser setting that I can change?I'll let you know if I get the same problem with JavaScript as I am getting with VBScript.It's all fun and games till someone loses their data. :)Dooberry
  14. There's a lot of support here. Try creating a new text file with the following tags in Notepad:<html><head></head><body></body></html>This can act as a template for anything you want to try out. If you see some code that is supposed to do what you want, copy and paste it in between the opening tag (e.g. <head>) and the closing tag (</head>). Then mess around with the code until it works. Then try and figure out what you did.This is how I've learned the basic stuff and after that you can start to build. Hope this was helpful - Dooberry.
  15. With apply-templates, you can choose the order in which they appear. <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"><body> <xsl:apply-templates select="FromFile" /> <xs:apply-templates select="Matrix" /> </body></html></xsl:template><xsl:template match="FromFile"> <table border="1"> ... </table></xsl:template><xsl:template match="Matrix"> <table border="1"> ... </table></xsl:template> I think this will do it, you don't actually need to name the templates to apply them, I'm not sure if you would need to change the reference in the apply-templates tag to the template name if you needed to use the template names for another reason.I've played around with this myself and it works in IE, but let me know if you run into any problems.Dooberry
  16. I just checked the xpath functions and there is a distinct-values function for xsl. This should fix the problem.Unfortunately I can't see any sample code for it.Dooberry
  17. I've sorted loading up a file and editing the data using a form, the problem I seem to have now is that Explorer won't let me save the file after I've changed the information.I've written the following script in the xsl file that I've loaded dynamically:Sub submitrecord Dim xmldoc, rootel, nodeel-- this loads the document into a variable -- set xmldoc=CreateObject("Microsoft.XMLDOM") xmldoc.load("QuoteContact.xml") xmldoc.async="false"-- this parses through the document nodes that I need to edit and gets their new values from controls on the current page -- set rootel=xmldoc.documentelement set nodeel=rootel.selectSingleNode("FAO/Contact") nodeel.text=Document.getelementbyid("faocontact") set nodeel=rootel.selectSingleNode("FAO/FAOCompanyname") nodeel.text=Document.getelementbyid("faocompany") set nodeel=rootel.selectSingleNode("FAO/FAOAddress1") nodeel.text=document.getelementbyid("faocompanyaddress1")-- this is where the problem starts - I get the message "Access is denied". I'm using a local file path to store the xml, but it's as if the file is locked when I load it -- xmldoc.save "c:\mynewquotecontact.xml"-- this is where I free up the memory pointers -- set xmldoc =nothing set root = nothing set node = nothing End Sub Can anyone tell me if I can open the xml document using the load method without creating a lock on the file?Any help would be greatly appreciated.Dooberry
  18. OK,Having just checked out what namespaces are for I think I've found a use for them.
  19. This is also brilliant for another reason - part of what I am doing involves a user entering data to prepare a document in varous xml stores (one for each part of the document). The user will then get a preview of the document at the end which will be a group of transforms all shown as one page (document.write will allow me to do as many transforms per page as I want). Once they're happy with the preview, the data will be transmitted to a database in its component parts.
  20. Hmm, I didn't put the speechmarks around the boolean values (DOH!!!). That works great now. My apologies for being a prat.Dooberry.
  21. I don't know too much about namespaces and their effects on XSL,but what I have found is that it is more successful to create a template for each element and then have the root template apply them all:<xsl:template match="/"><html><body><xsl:apply-templates /></body></html></xsl:template><xsl:template match="tag1"><p>Tag One: <xsl:value-of select="tag1"><p></xsl:template><xsl:template match="tag3"><p>middle tags: <xsl:value-of select="tag3"/></p></xsl:template>This way, you don't need to use the <xsl:for-each> because the template will apply every time it encounters an element called tag3.Give it a go and let me know if it helps.Dooberry.
  22. I guess nobody cares enough to answer.Dooberry
  23. All these posts and still no answers. I'll put this down to the fact that this shouldn't happen and it must be the way my company installs software.Never mind.Dooberry - The only person who will speak to me
  24. Can you just use ADO in an XSL sheet to upload the xml nodes into the appropriate location on the database?I'm trying to do a similar thing myself, but I'm testing it with Access first.If the technique works in Access, then you can just change the provider for the ADO object as long as the server structure matches the access structure.
  25. I don't know if anyone will help me (especially as no one seems to have an answer for my previous post about scripted XSL ). I'm having trouble using XSL apply-templates on a document with different sibling elements.If I do a transform on data for one of the child elements, the browser still reads the data from it's sibling, even though there is no template for the sibling, and just shows the sibling's values as text.Does this mean that all sibling elements must have identical child nodes?Does this mean that childnodes must be leaves and not complex elements?Does this mean that IE6 can't use apply-templates properly?Worse still (and probably more likely), does this mean that I can't use apply-templates and XML properly?If I am trying to create a complextype, comprising different complextype structures (to mirror a relational database), is there a best way to do this?Please help, I'm getting tired.
×
×
  • Create New...