0

I just got a website assignment and it server apparently does not support databases. So I was thinking, in a traditional XML DTD...we have data like this:

<book category="CHILDREN">
    <title>Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
</book>

Using Text Boxes and maybe by linking using XSLT or something else, can I add/insert more data into my existing XML sheet??

Also, can I perform validation such as no duplicate titles??

I'm kind of new to this and some help would be appreciated.

4
  • 1
    Hi Aditya. Your question is very broad and it is not possible to answer it shortly, without writing a long tutorial, making lots of assumptions about your server, your data, your technology, your use cases, etc. Try asking more detailed questions to concrete problems...
    – Lukas Eder
    Nov 21, 2011 at 8:59
  • Actually...I am creating an XML sheet as given above. I need to know if there is any way in XSLT by which I can add more rows of data as shown above. Ok...the validation can be done later! Nov 21, 2011 at 13:04
  • Hi Aditya, What XML parser are you using? In our XML based applications we do Create / Update / Delete (CRUD) using DOM methods, on the server, and limit XSL to formatting XML as HTML for the client (browser). Nov 21, 2011 at 16:12
  • I'm relatively new. Basically, I want to do away with using a dedicated database. I'm just creating one HTML file with XSLT... and an XML file with the xml. Then I link the two and I'm trying to add in data... Nov 21, 2011 at 18:50

1 Answer 1

0

If this is about adding "rows" to your book "record", then you can do this

<xsl:template match="/">
  <xsl:apply-templates/>
</xsl:template>

<!-- match book explicitly ... -->
<xsl:template match="book">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>

    <!-- and add one "row" to the books content -->
    <one-more-row>value</one-more-row>
  </xsl:copy>
</xsl:template>

<!-- Just copy all the other elements/attributes (including book contents) -->
<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

Not the answer you're looking for? Browse other questions tagged or ask your own question.