Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 21st, 2006, 08:41 PM
Authorized User
 
Join Date: Mar 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default New to XML. Have a couple basic questions

I am trying to learn XML, and am working on an application while learning. I currently have a XML file with all my data, and am displaying it with a XSL file, and with vbscript.
Displaying the data works ok, but I am completely lost where to even start when it comes to updating the data file.

XML:
<breaks>
    <slot>
        <slotno>1</slotno>
        <time>0:00</time>
        <status>open</status>
        <available>3</available>
        <counter>0</counter>
        <name>
            <user>sswingle</user>
            <type>lunch</type>
        </name>
        <name>
            <user>user2</user>
            <type>break</type>
        </name>
    </slot>
    <slot>
        <slotno>2</slotno>
        <time>0:15</time>
        <status>closed</status>
        <available>3</available>
        <counter>0</counter>
        <name>
            <user>sswingle</user>
            <type>lunch</type>
        </name>
        <name>
            <user>user3</user>
            <type>break</type>
        </name>
        <name>
            <user>user4</user>
            <type>rr</type>
        </name>

    </slot>
    <slot>
        <slotno>3</slotno>
        <time>0:30</time>
        <status>closed</status>
        <available>3</available>
        <counter>0</counter>

    </slot>
    <slot>
        <slotno>4</slotno>
        <time>0:45</time>
        <status>open</status>
        <available>3</available>
        <counter>0</counter>

    </slot>
</breaks>

My XSL File:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
<script language="vbscript">
Sub B1_OnClick
Dim slot
Dim name
Dim typeofbreak

    slot= InputBox("What time slot")
    name= InputBox("Your Name")
    typeofbreak = InputBox("Restroom, Break, or LUnch")
    Msgbox ("Thank you, your break has been scheduled")

End Sub

</script>
  <body>
    <h2>Breaks</h2>
    <table border="1">
      <tr>
        <td bgcolor="#3399ff">Time</td>
        <td>Status</td>
    <td>Legend</td>
    <td bgcolor="ff9933">Short Break</td>
    <td bgcolor="3399ff">Break</td>
    <td bgcolor="ffff00">Lunch</td>
      </tr>
      <xsl:for-each select="breaks/slot">
      <tr>
        <td><xsl:value-of select="time" /></td>
    <xsl:choose>
        <xsl:when test="status='open'">
                <td bgcolor="00ff00">
        <xsl:value-of select="status" /></td>
            <td><form><input type="submit" value="Request" name="B1"></input></form></td>
        </xsl:when>
    <xsl:otherwise>
        <td bgcolor="ff3300"><xsl:value-of select="status" /></td>
    </xsl:otherwise>
    </xsl:choose>
        <xsl:for-each select="name">
        <xsl:choose>
            <xsl:when test="type='rr'">
                <td bgcolor="ff9933"><xsl:value-of select="user" /></td>
            </xsl:when>

            <xsl:when test="type='break'">
                <td bgcolor="3399ff"><xsl:value-of select="user" /></td>
            </xsl:when>

            <xsl:when test="type='lunch'">
                <td bgcolor="ffff00"><xsl:value-of select="user" /></td>
            </xsl:when>

        </xsl:choose>

        </xsl:for-each>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

What I cannot figure out are two parts.
1. Needing the program to know which button is clicked so the slot is known automatically
2. Being able to add the given information to the XML file and resaving the XML file.

Im sorry if this is too complicated. If someone can give me an example of saving information to an XML file that would be great. My only requirement is that I DO NOT use asp, everything needs to be client side processing.

Thanks!!

 
Old April 22nd, 2006, 04:03 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The way you update the XML document is to write a bit of Javascript that responds to the button click and fires off an XSL transformation to do the update, creating a new document. You can use the Microsoft API or the Sarissa cross-browser API. Writing the XML document back to filestore is more difficult. You don't say whether it's client filestore or server filestore, but either way, there are security issues. This isn't directly an XML problem and it's not an area where I claim any expertise. I would normally assume some kind of servlet, ASP page, or similar on the server.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 22nd, 2006, 07:13 AM
Authorized User
 
Join Date: Mar 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just want to save the XML back to the local client, C:\temp will be fine. Wanting to use the Microsoft API. vbscript is preferred over javascript, but if you can give an example of how to do either that would be great.
I cannot do any server side processing, so ASP is impossible in this situation.

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Couple questions about embedding values into html warhero XSLT 2 July 3rd, 2007 03:06 PM
Visual Basic 6.0 and XML garyjh All Other Wrox Books 5 April 25th, 2005 09:44 AM
A couple of questions: czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 4 March 23rd, 2005 03:13 PM
Basic help questions... mpmahoney Access 2 December 15th, 2004 08:41 AM
some basic questions kirangnvs Biztalk 0 September 23rd, 2004 04:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.