Jump to content

XSL within XSL


dooberry

Recommended Posts

Guys,I've not tried to do it yet so don't mock me.. Is it possible to use an xml document as a list of options for a drop down box that is separate from the document which stores the data?I would like to be able to update the options discreetly from the xsl template to save having to re-write the whole document (or even sections of it).I guess I was wondering if an xsl template can transform separate xml documents at the same time (is this what namespaces are for?).Any advice would be appreciated (if there was a begging bowl smilie I'd use it right here!!).Dooberry. :)

Link to comment
Share on other sites

Ok I think I can see a way this might work.If I plug an invisible frame into the document, it can read a different source page to the rest of the document and I can change the nodes using vbscript.If I get this working I'll post the code for other people to look at.Dooberry

Link to comment
Share on other sites

Took some figuring out.I'm disappointed that you can't bind use the datasrc object in a form and you can only use it in a table. It'll all be much better when XFORMS get switched on and there'll be much less messing about with scripts.For the time being, this could be ideal, I can have 2 data islands and I can bind the select element to one of the fields in the alternative data source.This means I don't have to change the form to update lists - Woohooo!!!!.The only thing is that I'll have to use XMLDOM to update the xml file with the changes to the input fields.I'll post the code when I've finished for other beginner developers. Dooberry :)

Link to comment
Share on other sites

I'm not sure of your entire applcation, but if you have server side includes (SSI) available, I've taken all my <option> code and put them in an include. So that I can use that include where ever I might need it. This is especially easy when that list of choices is dynamic - data driven include for <option> in a select - hmmmm so nice - like Baileys Irish Cream and Hot Chocolate on a 3 degree day.(btw, man its cold today)

Link to comment
Share on other sites

I can see where you're coming from, but unfortunately I am writing entirely on the client side, the idea is the client will create xml files on the client side from the html form and the data from these will be posted through ADO to the server.I'm having trouble trying to get the select element to work.I've got a data island to populate text input elements without a problem, but I want the options in the select element to read from a separate xml data island.This is easy with an xsl sheet:

<select id="selectid"><xsl:for-each select="optionfield">  <option>      <xsl:attribute name="value">         <xsl:value-of select="fieldvalue" />      </xsl:attribute>      <xsl:attribute name="selected">          <xsl:value-of select="optionselected" />      </xsl:attribute>  </option></xsl:for-each></select>

but the problem arises when I want the options for the select element to be stored outside the xml output. Using script to do this is easy, because I can use document.write to transform as many xml documents on one page as I like (this is a useful feature for later in the process), but I would like to avoid the script, if at all possible, for re-usability.Is there a way I can get round this using multiple data islands?If there is, can someone help me with the code please?

Link to comment
Share on other sites

  • 1 month later...

Ok I think I've found out how to express the nature of the problem clearly.It's a similar idea to frames. If I create frames on a page, each with their own source page, can the page which contains the frames reference the objects in each frame?For example:

<html><script language="vbscript">   dim object1      object1=document.getelementbyname("frame1contentobject1")      msgbox "you entered " & object1.value</script><frameset rows="80%,20%">  <frame name="frame1" src="frame1content.htm" />  <frame name="frame2" src="frame2content.htm" /></frameset></html>

If anyone can help with this it would be most useful.Dooberry Pie.

Link to comment
Share on other sites

Isn't it most convient to store the sctipt(s) in external file(s) and reference them with the "src" attribute inside the pages themselves(not the frameset that is)?

Link to comment
Share on other sites

  • 1 month later...

Ok,Boen_ I looked at some of your other posts to see if they would give me any ideas and I came up with the following -Let's say I use <xsl:variable> to define a variable which will refer to an xml file (have you guessed what it is yet?) - Can I then change the file my variable contains so that I can transform different documents to create the layout I require?If so how do I get the variable to contain a whole xml structure?Dooberry pie and warm custard :) .

Link to comment
Share on other sites

Woohoo!!!!!I've included the following link because it's just solved the problem:treasure trove of infoI've also included the stylesheet code (but not the xml file because it's confidential) so that other people can use this.I've not finished it yet, though because the Select control in the code doesn't submit a value at present (but I'll soon change that!!).Here you go:

<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="Quote"><html><script type="text/vbscript">	Sub submitrecord  Dim xmldoc, updatednode, rootel    set xmldoc=CreateObject("Microsoft.XMLDOM")  xmldoc.async="false"    xmldoc.load "quotecontact.xml"  set rootel = xmldoc.documentelement  set updatednode = rootel.selectsinglenode("contact")  updatednode.text = document.getelementbyid("contact").value  set updatednode = nothing  set updatednode = rootel.selectsinglenode("ASM")  updatednode.text = document.getelementbyid("manager").value  set updatednode = nothing    set updatednode = rootel.selectsinglenode("companyname")  updatednode.text = document.getelementbyid("company").value  set updatednode = nothing    set updatednode = rootel.selectsinglenode("address1")  updatednode.text = document.getelementbyid("companyaddress1").value  set updatednode = nothing  set updatednode = rootel.selectsinglenode("address2")  updatednode.text = document.getelementbyid("companyaddress2").value  set updatednode = nothing  set updatednode = rootel.selectsinglenode("address3")  updatednode.text = document.getelementbyid("companyaddress3").value  set updatednode = nothing    set updatednode = rootel.selectsinglenode("town")  updatednode.text = document.getelementbyid("companytown").value  set updatednode = nothing	  xmldoc.save "quotecontact.xml"      set updatednode = nothing  set rootel = nothing  set xmldoc = nothing	End Sub	Sub cancelrecord  msgbox "you clicked Cancel"	End Sub</script><body><select id="manager"><xsl:for-each select="document('ASMS.xml')//ASMS/ASM">	<option>	<xsl:attribute name="value" >  <xsl:value-of select="areacode" />	</xsl:attribute>	<xsl:value-of select="ASMname" />	</option></xsl:for-each></select><xsl:apply-templates select="contact" /><xsl:apply-templates select="companyname" /><xsl:apply-templates select="address1" /><xsl:apply-templates select="address2" /><xsl:apply-templates select="address3" /><xsl:apply-templates select="town" /><input type="button" id="dealdefnext" onclick="submitrecord" value="Next>>"/><input type="button" id="cancel" onclick="cancelrecord" value="<<Cancel"/></body></html></xsl:template><xsl:template match="contact"><table width="100%" border="0" padding="2"><tr><td width="20%">Contact:</td><td>	<input type="text" id="contact" maxlength="50"><xsl:attribute name="value">	<xsl:value-of select="." /></xsl:attribute></input></td></tr></table></xsl:template><xsl:template match="companyname"><table width="100%" border="0" padding="2"><tr><td width="20%">	Company:</td><td>	<input type="text" id="company" maxlength="50">	<xsl:attribute name="value">  <xsl:value-of select="." />	</xsl:attribute>	</input></td></tr></table></xsl:template><xsl:template match="address1"><table width="100%" border="0" padding="2"><tr><td width="20%">	Address:</td><td>	<input type="text" id="companyaddress1" maxlength="50">	<xsl:attribute name="value">  <xsl:value-of select="." />	</xsl:attribute>	</input></td></tr></table></xsl:template><xsl:template match="address2"><table width="100%" border="0" padding="2"><tr><td width="20%" /><td> 	<input type="text" id="companyaddress2" maxlength="50">	<xsl:attribute name="value">  <xsl:value-of select="." />	</xsl:attribute>	</input></td></tr></table></xsl:template><xsl:template match="address3"><table width="100%" border="0" padding="2"><tr><td width="20%" /><td> 	<input type="text" id="companyaddress3" maxlength="50">	<xsl:attribute name="value">  <xsl:value-of select="." />	</xsl:attribute>	</input></td></tr></table></xsl:template><xsl:template match="town"><table width="100%" border="0" padding="2"><tr><td width="20%" /><td> 	<input type="text" id="companytown" maxlength="50">	<xsl:attribute name="value">  <xsl:value-of select="." />	</xsl:attribute>	</input></td></tr></table></xsl:template></xsl:stylesheet>

:):):(:D:):blink::( Well done akaii!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...