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 June 18th, 2007, 11:44 AM
Authorized User
 
Join Date: Mar 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Extracting a value and displaying in popup

Hi All...

I am looking for a way of extracting a value from a XML parameter and displaying it in a page that pops up via a link. For example, take a look at http://www.mamaliga.com/onlineschedu...s_3_months.xml

If you click on one of the red "1 (available)" headers, you'll be presented with a couple empty hour slots in that day.

Well I'd like to pass the time value on which the user clicked (9:00 am) to the pop-up window that is opened from that particular link, and display that value as text (up in the red colored header "Time Slot:").

For now, this is how I make those links available:

XML:
Code:
<Time href="javascript:DET('appdemo.xml')" slot="9:00 am"/>
XSL:
Code:
<xsl:template match="Time">
<xsl:text/>
<li>
<a CLASS="Item">
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
<xsl:value-of select="@slot"/>
</a>
</li>
</xsl:template>
Thanks a lot!
Gabi.

 
Old June 19th, 2007, 07:35 AM
Authorized User
 
Join Date: Jun 2007
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear gabster

You should pass slot attribute to your popup dialog. I think it's better to change your DET function (in os_3_months.xsl) so that it could accept an slot as a second parameter.

You used 'window.open' to display schedule popup to user. I recommend you to use 'window.showModalDialog' or 'window.showModelessDialog' so that you can pass arbitrary parameters to your popup. Both of these methods accept a url as a first parameter and their second parameter, named 'Arguments', is a javascript object that you can pass to popup window. You should send 'slot' attribute ("9:00 am") using this parameter.

So your DET function would be something like this :

function DET(url, slot, width, height)
{
var Win = window.showModalDialog(url,slot,'width=' + 780 + ',height=' + 330 + ',
            resizable=0, scrollbars=yes, menubar=no, status=no' );
}

You can access this parameter in popup window through 'dialogArguments' property of window object. It means that you should make some changes in your popup window source code so that it displays this parameter just after 'Time Slot:' label.

Find


<b>Time Slot:</b>


in your appdemo.xsl and replace it with :


<b>Time Slot:</b> <SCRIPT language='javascrip'>document.write(window.dialogA rguments)</SCRIPT>


Also remember to change your <Time> tag to :

<Time href="javascript:DET('appdemo.xml', '9:00 am')" slot="9:00 am"/>


Good luck
 
Old June 25th, 2007, 11:20 AM
Authorized User
 
Join Date: Mar 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a TON!!!

It makes sense!

However, I am getting an empty popup for some reason. No javascript errors though... Check the first 9:00 slot from the first red "available" drop-down (Jan 1st).

I wonder if there are some timing issues to run the java script.
thanks!
Gabi.
 
Old June 25th, 2007, 11:40 AM
Authorized User
 
Join Date: Mar 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem solved.

Yes - I needed to make a separate htm that has a code that actually joins the XML and the XSL together:

<html>

<body>

<script language="javascript" for="window" event="onload">

// Load XML

var xml = new ActiveXObject("Microsoft.XMLDOM")

xml.async = false

xml.load("appdemo.xml")


// Load the XSL

var xsl = new ActiveXObject("Microsoft.XMLDOM")

xsl.async = false

xsl.load("appdemo.xsl")

document.write(xml.transformNode(xsl))

</script>

</body>

</html>


Thanks!
Gabi.

 
Old June 28th, 2007, 09:28 AM
Authorized User
 
Join Date: Mar 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

INteresting fenomenon:

I have no problem opening the popup from a Internet Explorer 6, but not from version 7. There I get this error:

"Automation Server can't create object" (???)

Any thoughts?

thanks,
gabi.






Similar Threads
Thread Thread Starter Forum Replies Last Post
extracting attribute value hag XSLT 1 March 3rd, 2008 03:16 AM
Extracting Text Jeff Mason BOOK: Beginning Regular Expressions 1 October 24th, 2006 06:38 AM
extracting atributes - how to do this? zoreli XML 6 August 12th, 2006 03:46 AM





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