Jump to content

dooberry

Members
  • Posts

    133
  • Joined

  • Last visited

Everything posted by dooberry

  1. It worked.This means I can add a node attribute to an input element and use this attribute to submit the data back to the xml file. <input id="myinputid" mynode="xmlelement/xmlnode" onChange="submitxml(this.mynode, this.value, 'myxmlfile.xml')" /> The stuff I've learned on here is so cool!! Dooberry.
  2. Thanks for the info guys that's cool.What I didn't want is for the attribute to be "thrown away" by the browser so that the Javascript couldn't see it.You could well be right about the xml prefix so I'll call it something like mynode (although it wouldn't surprise me if "node" isn't allowed either!!) I'll let you know if it does what it says on the tin.Dooberry
  3. Ok I simpered a bit in the title there, but if anyone could help I'd be grateful and you'll see why.I have an input field which reads from and writes to an XML node.The problem is that I had to write a function to do this and I would like to be able to define the node as a property of the input field e.g. :<input type="text" id="look at me" xmlnode="mydata/ishere" /> I know that "illegal" attributes are allowed in XHTML (it only audits the syntax not the content), but what I need to know is whether they are ignored by XHTML or if they create a new attribute for the item.If an xmlnode attribute would be created by the above tag then my problem would be solved, but if not then my code is doubled!Any advice?Dooberry
  4. Is there an HTML equivalent of a tool tip text?What I mean is something that appears under the cursor when you hover over an element to tell you what it does.I've seen this done with hyperlinks, but I want to use it for an image or input.Can anyone help please?Dooberry.
  5. Try right clicking on the XML file and selecting "Open With".You will then get a list of programs to open the file with and you can set one of them to be the default (IE).This is happening because Dreamweaver has been set as the default program for all ".xml" files.Hope this helps.Dooberry
  6. dooberry

    Select Nodes

    Have a look at this, I was trying to do a similar thing:Dooberry's excellent adventureI found a way to show the current value using <xsl:if> as well.I would suggest before you go any further you read through the XSL tutorials because XML data islands are not very effective, HTML is not really designed to do much with XML (without a lot of scripting!!).Hope you find something useful.Dooberry
  7. Thanks for the tips, they're always useful.We all know that Billy Gates is taking over the world though so it's only a matter of time before IE is the only browser you can get for your Xbox PC multimedia station complete with integral wallpaper!! :)I'm still a newbie really, just a busy one.
  8. dooberry

    Increment

    I think I've found a better way of doing this, function AddNewNode(){ var xmldoc var myelement var newnode var subnode xmldoc = new ActiveXObject("Microsoft.XMLDOM") xmldoc.async="false" xmldoc.load("myxmldoc.xml") myelement = xmldoc.documentElement newnode = xmldoc.createElement("On Sale") subnode = xmldoc.createElement("id") subnode.appendChild(xmldoc.createTextNode(String(myelement.childNodes.length +1))) newnode.appendChild(subnode) myelement.appendChild(newnode) xmldoc.save("myxmldoc.xml")} The alteration is minor, but significant in that there is now no need for a session variable and there is no need to update the session variable when you add records because the length property changes as you update the file.This also means that there are no problems if you forget to update the session variable!!.I'm not so green as I'm cabbage-looking (as we say in these parts). :)Dooberry.
  9. Nope,I lied, it works. Sorry for wasting everyone's time.
  10. Hi guys,I'm having some trouble. I don't want to use a button or an image for what I'm doing so I thought an anchor would solve the problem (except it doesn't). I need some text to trigger a function on my web page when it is clicked. I tries using an anchor without a URL attached to it, but it behaves as normal text and doesn't do anything.my code is: <a onclick="function()">click here for something to happen</a> I assume it's because the anchor is empty. Is there another tag I can use? Can anyone help please?Dooberry
  11. I've cracked it but I've also found something odd with the position() function.here is something that worked: <xsl:template match="item"><xsl:for-each select="."> <td> <xsl:value-of select="." /> </td></xsl:for-each><xsl:if test="position() mod 4 = 0" ><tr /></xsl:if></xsl:template> As a programmer it doesn't seem logical that the position() function has to be outside the for-each statement.This works because when the expression evaluates to 0 the <tr /> is added which is a closed table row (a table row with nothing in it!!).This is a shortcut for <tr></tr> that would work in place of <tr /> in the above code.I knew I'd get it in the end Dooberry
  12. What about trying <xsl:value-of select="'<tr>'" /><xsl:value-of select="'</tr>'" /> instead?I'm wondering if these text values will work by not being part of the html in the stylesheet.I've used this technique before to tell xsl to use a text value in value-of instead of select a node value.I'll try it and see what the results are.As these
  13. I don't think this needs much modification: <table><xsl:for-each select="ChineseWordList"> <xsl:for-each select="Word"> <xsl:sort select="PinYin"/> <xsl:if test="position() mod 20 = 1"> <tr> <xsl:if> <td> <xsl:value-of select="Chinese"/> <xsl:copy-of select="' '"/> </td> <xsl:if test="position() mod 20 = 0"> </tr> </xsl:if> </xsl:for-each></xsl:for-each><table> the only thing that might occur is an error because if the unmatched <tr> and </tr> tags in the xsl:if statements.Hope this helps, sorry if it doesn't :)Dooberry.
  14. HmmThe alternatives to this are a bit ropey. The thing is that information can be shared without being exported from one database to another - most database server systems will support linked tables from databases in another format e.g. SQL can link to Oracle and vice versa.Another means of copying the records could be through replication, but I've never heard of replication being used across different database formats.Another suggestion might be to load the xml files into a MySQL database then you don't have to interrogate the files. This would mean that you could share the information over the web from a database format and not have these monstrous xml files cluttering your systems.XML is a means of transferring data from one system to another in a language that they can both understand, no-one said that the XML data has to stay in XML format once it gets there.I don't know if that really helped or not, but hopefully it will have given you some ideas. :)Dooberry.
  15. dooberry

    Increment

    Ok, I don't think this is the best way of doing it, but I used java to create a session variable which will hold the total number of recordsvar no_of_records Then I've created a button to add records <input type="button" onclick="AddNewNode()" id="addrecord" value="Add New Record" /> I then used the following script to edit the xml file: function AddNewNode(){ var xmldoc var myelement var newnode var subnode xmldoc = new ActiveXObject("Microsoft.XMLDOM") xmldoc.async="false" xmldoc.load("myxmldoc.xml") myelement = xmldoc.documentElement newnode = xmldoc.createElement("On Sale") subnode = xmldoc.createElement("id") subnode.appendChild(xmldoc.createTextNode(String(no_of_records+1))) newnode.appendChild(subnode) myelement.appendChild(newnode) xmldoc.save("myxmldoc.xml")} This did work with my project although I'm sure there are tidier ways to do this than to have a session global variable. Hopefully someone will look at this and tell me that I'm still a rookie and show me where the code can be improved (68 posts does not a master make!!). Dooberry
  16. dooberry

    Increment

    If you are using id as an element and you can write ASP then have a look at the XMLDOM tutorial.I think if you use the MAX() function to get the highest ID value and then use script to add one to this value then you can store the new value as the ID of the new element.I'm going to be doing something like this with my current project so I'd be happy to compare notes when I've got it working.Dooberry.
  17. Just a thought -What happens if you don't define a constraint for the element within the schema?A constraint is exactly that - it is designed to ensure that data is of a fixed type.If there is no constraint does that mean that the data can be any type?Let me know if that helps (I'm not as advanced as I may look).Dooberry.
  18. I'm having the same problem as this guy but with Javascript.I thought you could use double quotes to indicate speechmarks within a string e.g. '' or "" but I can't get it to work.In my case though, it would be easier if anyone can tell me how to add a custom attribute to a control as this would get round the problem.
  19. I would suggest redesigning the element: <address> <building>28</building> <road>Thomson Road</road> <postcode>75500</postcode></address> Instead of using this as an attribute, you can then make it a sub-element of you main element: <objectelement> <data1> <data2> <data3> <address> <building>28</building> <road>Thomson Road</road> <postcode>75500</postcode> </address></objectelement> This will make it easier to navigate the address.Usually attributes are saved for things like id or colour (although these can also be treated as elements), because these are more likely to be used as attributes by HTML - that's how I think of it anyway.In theory, you don't have to have any attributes at all!!Dooberry.
  20. dooberry

    Manipulate xml files

    I think ADO is generally shown as a server side language, but when you look at it objectively (excuse the pun!! ) it's just a set of objects that can be manipulated to connect to and change a database. As long as you have the libraries, you can use ADO - it's just easier to manage with server side scripting because the libraries are on the server instead of having to be on each client.In my case I can use it because I know that all of the clients that will be using the system will have ADO installed, but this would not be the case for everyone.Dooberry.
  21. I cracked it!!!I used a variable to get the data that had been entered.Then I used xsl:if to compare this to the list item.Within xsl:if I defined the selected attribute as the current list item.Here is the code: <select id="selectcontrol"><xsl:for-each select="document('xlist.xml')//xlistitems/listitem" ><xsl:variable name="entereditem" select="document('xdata.xml')//xdata/item1" /><option><xsl:attribute name="value" > <xsl:value-of select="listitem" /></xsl:attribute><xsl:if test="listitem=$entereditem"><xsl:attribute name="selected"> <xsl:value-of select="'selected'" /></xsl:attribute></xsl:if></option></xsl:for-each></select> Here endeth the lesson!!Dooberry
  22. dooberry

    Manipulate xml files

    Actually it is possible to (ab)use xslt to write to a database.XSL allows you to write script (java or vb) within the stylesheet and you can (ab)use this to put ADO to work on the data.You could execute the ado transactions using XMLDOM to read the xml file you create.You guys probably aren't stuck with notepad like I am though so have fun using all your fancy IDE!!! :)Dooberry.
  23. I want to set a value for an attribute that isn't stored in the xml file.What I have is an xml file with some data in it.I am then populating a Select control with data from another XML file.I want the Select control to show the item which corresponds to the value in the data store using the "selected" attribute of the select control.e.g. <xdata><item1>400</item1></xdata> is in the data file.in the list we have <xlistitems><listitem>100</listitem><listitem>200</listitem><listitem>300</listitem><listitem>400</listitem></xlistitems> To create the dropdown I have code which says: <select><xsl:for-each select="document('listitems')//xlistitems/listitem"><option><xsl:attribute name="value"><xsl:value-of select="listitem"></xsl:attribute></option></xsl:for-each></select> What I want to do is add the selected attribute if the value of listitem matches the value in xdata/item1.Firstly, is this explained ok and secondly can anyone help please??? :)Dooberry
  24. Dooberry Strikes Again!!:)I've sorted it.What I've done is create the following script in the hta file: function submitxml(nodeelement, nodevalue, nodedocument){var xmldocvar rootelvar selectednodexmldoc = new ActiveXObject("Microsoft.XMLDOM")xmldoc.async="false"xmldoc.load(nodedocument)rootel = xmldoc.documentElementselectednode = rootel.selectSingleNode(nodeelement)selectednode.text = nodevaluexmldoc.save(nodedocument)} then in my xsl file, where it defines the input control for the node I have attached this function to the onChange event. <xsl:template match="hypotheticalnode"><input type="text" id="hyptheticaltextbox" onchange="submitxml('hypotheticalnode',document.getelementbyid('hyptheticaltextbox').value,'hypotheticaldoc.xml')" /> When I then carry out the transform and dump the html in the table cell using the innerHTML property, there is no code and the change event triggers the submitxml() function in the main page -- WOOHOO!!!This will now allow me to edit a document on the client.I'll finish this project and then put the pages on the XML forum for anyone who wants to re-use the code.Dooberry (works very hard!!)
×
×
  • Create New...