Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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 January 24th, 2006, 01:47 PM
Authorized User
 
Join Date: Oct 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default insert data param into xml from external file

I am knocking up a simple content management system that will manage the text in an existing multi-language web application.

Each screen of the main application has a corresponding XML file which contains all the text to be displayed on that screen, and there is a seperate file for each language.

The content file is loaded by the XSLT stylsheet which produces the screen:

<xsl:param name="content.xml" select="document(concat('../xml/',$lang,'/filename.xml'))" />

Within the xml file there are a number of different elements for headings, labels, etc, which only contain plain text, which can be manipluated by the user of the CMS using text inputs as normal.

However, The 'paragraph' nodes contain HTML, which is produced by a WISIWIG editor, so that the user can control the fomatting.

The files look something like this

<Headings>
    <Heading id="h1" content="Welcome"/>
</Headings>
<Labels>
    <Label id="l1" content="Your Name"/>
</Labels>
<Paragraphs>
    <Item id="p1">
        <p>Welcome to the system, please enter your <b>name</b> below</p>
    <Item>
</Paragraphs>

At the moment the paragraphs are displayed on the application screen by using xsl:copy-of.

<xsl:copy-of select="$content.xml/Paragraphs/Item[@id='p1']"/>

So far so good. Now comes the tricky bit...

I need to be able to insert a piece of data from the application xml (the xml document which the xslt is transforming) into a point within the paragraph xml.

for example, if I were to define this paragraph in the xml file:

<Item id="p2">
    <p>You have <num_attempts/> attempts left to get it right</p>
<Item>

How can I display that paragraph on the screen with <num_attempts/> replaced with a figure from the application xml, only by using XSLT?

Feel free to suggest other ways in which i can do this, but the application xslt has to load the content from a static xml file.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
append/insert data to xml file andhiez XML 5 April 18th, 2008 11:13 AM
getting data from XML and insert it into a databas belete XML 3 November 20th, 2007 12:38 PM
Error 'SQL_C_NUMERIC' with param Insert query bnorg MySQL 0 December 16th, 2006 07:30 PM
how to Insert data into external db method Access VBA 5 May 4th, 2005 10:59 AM
Reading from external data file peter_budo C++ Programming 5 December 14th, 2004 03:06 PM





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