Jump to content

dooberry

Members
  • Posts

    133
  • Joined

  • Last visited

Everything posted by dooberry

  1. Going on Boen's (aka XML Sifu) reply I think I can see what's happening here and make a bit more sense of the post.I think that you are submitting an invalid parameter.The first statement (as Boen said) selects all of the child elements with the value A.I have no knowledge of PHP whatsoever so disregard this if it sounds like b*ll*cks, but surely the second statement should be more like:for $d in doc("blabla.xml")//tag/tag2[tagsent/tagsent2=A]to mirror the effects of the first one (I'm assuming that XPATH syntax will work here)D
  2. I've done something similar but not using images.If you want to change the side menu based on the top menu, you need something to refresh the page after you've re-transformed it.What I would do is put something like this into effect:Have one xml element in the image document which stores the menu selection that the user clicked (i.e. Blue, Pink, Yellow etc). <images><portrait type="blue" image="images/blue1.jpg" thumb="/images/thumbs/blue1.jpg" description="This is blue " /><portrait type="blue" image="images/blue2.jpg" thumb="/images/thumbs/blue2.jpg" description="This is also blue! " /><portrait type="yellow" image="images/yellow1.jpg" thumb="/images/thumbs/yellow1.jpg" description="This is yellow" /><portrait type="pink" image="images/pink1.jpg" thumb="/images/thumbs/pink1.jpg" description="This is a pink color" /><portrait type="pink" image="images/pink2.jpg" thumb="/images/thumbs/pink2.jpg" description="This is also a pink color" />[b]<current>*</current>[/b]</images> You can then use the content of this document in the xsl sheet by using the following xsl <input type="button" onclick="Reloadpage('pink')">Pinks</input><xsl:variable name="selection" value-of select="current" /><xsl:for-each select="/images/portrait[@type=$selection]" ><image onclick="document.getElementById(mainimage).src=this.image"><xsl:attribute name="src"><xsl:value-of select="@thumb" /></xsl:attribute><xsl:attribute name="image"><xsl:value-of select="@image" /></xsl:attribute></image><br /></xsl:for-each> Then you write script to update the html property of the div/frame that you are using: <script type="text/javascript">var xmldoc, xsldocxmldoc = new ActiveXObject("Microsoft.XMLDOM")xsldoc = new ActiveXObject("Microsoft.XMLDOM")xmldoc.load("images.xml")xmldoc.async = "false"xsldoc.load("images.xsl")xsldoc.async = "false"function Reloadpage(itemvalue){xmldoc.selectSingleNode("current").text = itemvaluexmldoc.save()document.clear()document.write(xmldoc.transformNode(xsldoc))}</script> Ok, it's really hot and I'm exhausted!!If this doesn't help the let me know and I'll see what I can do.D
  3. The above example works great, but you could go one step further.If you don't want to have to know the value of categoryid you could just change the Where clause to WHERE categories.categoryname = 'Golf' OR categories.categoryname ='Male' This is useful if the id is system generated for each category.
  4. dooberry

    select sum()...

    If you only want the totals, then try this (based on your example above) SELECT Fname, Lname, sum(trns) as totalFROM tableGROUP BY Fname, Lname This will also work across a valid join between two tables.
  5. You don't need to write the ALTER table statement twice, you can separate the fields with commas: ALTER TABLE dbname.dbo.tablenameADD columnA bit Default 0 Not Null, columnB bit Default 0 Not Null
  6. Remove "WHERE read=false".Also try this instead: SELECT account.address, count(email.id)FROM accounts INNER JOIN emails on accounts.account = emails.account This is much more straightforward because the subviews you have written are not needed. Only use views instead of tables in a JOIN clause to condense or transform the information that you need to look at - this usually is a technique you would use where you have a table with many fields and you need to minimise the amount of network traffic / server load by reducing the data retrieved.
  7. dooberry

    Unique ID

    Err, applying the relational database principle (XML is a similar beast after all) to this, isn't the whole point of a unique id to be *ahem* a unique id?Why do you need to add data with a null id and how on earth are you going to identify it when you try and look for it?If the second table is effectively on the "many" end of the relationship in the unique id then fair enough because that means that it doesn't have a "parent" record, and yes you would have to allow dbnull.The alternative is that you populate the unique-id automatically so that you don't have to worry about the null value issue.
  8. I agree with Boen (who is now my involuntary mentor!), but what I'd say is if you want to show the xml using your own html, dont use data islands and instead copy your html into your style sheet and replace the XML data links with <xsl:for-each>.for example: <table><thead><tr align="left"><th>Steam_id</th><th>Name</th><th>Kills</th><th>Deaths</th><th>Suicides</th><th>Headshots</th><th>Kd_ratio</th></tr></thead><xsl:for-each select="User"><tr align="left" onclick="testclick(this)"><td><xsl:value-of select="steam_id" /></td><td><xsl:value-of select="name" /></td><td><xsl:value-of select="kills" /></td><td><xsl:value-of select="deaths" /></td><td><xsl:value-of select="suicides" /></td><td><xsl:value-of select="headshots" /></td><td><xsl:value-of select="kd_ratio" /></td></tr></xsl:for-each></table> Then all you need to do is apply the stylesheet, which is something you can do in either XMLDOM (javascript) or within the XML file itself.You seriously need to look at the XSL tutorial first though - it's great and you can see where you've gone wrong when you try stuff out.
  9. dooberry

    xquery help

    get rid of the speechmarks around pubdate: <xsl:value-of select="substring(pubDate,1,15)" /> If you use speechmarks inside an xpath expression/function then xpath thinks that you have put a value between the speechmarks, not the name of the element you need to look at.To see what I mean try: <xsl:value-of select="pubDate" /> and then try: <xsl:value-of select="'pubDate'" />
  10. I've used this to another end as well now.Instead of "jumping" between nodes based on a user entry, I can also use this to identify where key values have not been entered: <xsl:choose><xsl:when test="item_qty"> <xsl:input id="qty"> <xsl:attribute name="value"> <xsl:value-of select="item_qty" /> <xsl:attribute/> </xsl:input></xsl:when><xsl:otherwise>You have not entered the quantity.</xsl:otherwise></xsl:choose> This is a useful way to eliminate schema (because I don't have the facilities to use them!).
  11. dooberry

    CSS in XSL

    Please refer to this topic for further details:bang your head long enough and you can break through the wall!!
  12. dooberry

    HELP!!!!

    This might work, but I think I know another way round it.The innerHTML property is still allocating the class attribute, so I can move the class definition out of the XSL sheet and into the 'home page'.This should allow the home page to understand the style required when the class is allocated.edit: It worked - I was stuck in my box again!Thanks for all your help guys - sorry to be a nuisance.Also if anyone is reading this post looking to change the text content of a div dynamically you can do it this way: document.getElementById('divelementid').removeChild(document.getElementById('divelementid').childNodes[0])document.getElementById('divelementid').appendChild(document.createTextNode(textcontent)) Well shizzle my nizzle!
  13. dooberry

    HELP!!!!

    Ok,I have an idea using an iframe.I can write to the content of the iframe, but is there a way of calling script functions which are outside of the document in the iframe? If this works, then the same should be able to be done with frames.I need to be able to manipulate a global variable which stays as the content of the iframe changes any ideas?
  14. dooberry

    HELP!!!!

    Yeah, you're right and that is the problem.What I'm trying to do is find a property (Javascript type property) within the div element that has a write() method.If I can do this, then I can change the content dynamically and not have things like script and styles stripped out of the html inside the div element.what I am looking to be able to do is something like: document.getElementById("displaydiv").whateverthecontentobjectis.write(myxmlddocument.transformNode(thexsltransformdocument)) I know that this can't be done using the innerHTML property because I've tried it and it will only add HTML elements, not style or script elements.The reason I have to do it this way is because the styles are allocated dynamically by the XSL sheets, and storing them in the main webpage is not an option.If you know of such a property then that would be great.Dooberry sits rocking in the corner.EDIT: PS My name's Dan too!
  15. dooberry

    HELP!!!!

    Guys,I'm having real trouble here and I've resorted to spamming a little (my profuse apologies!).Can anyone tell me how to dynamically write content to a div element.I've tried using the InnerHTML property, but that cleans out functional elements such as script and style.It is not possible to change the outerHTML property dynamically because Explorer doesn't allow it.I've had this problem before with table cells and frames are not suitable for the project.I thought there might be something within the div element like div.body.document, but I can't find anything.Please help!Dooberry
  16. Does anyone know how to access the body of a <div> element through it's properties?What I want to do is use find a document object that is within the div element so that I can dynamically change the content using document.write().The reason I can't use the InnerHTML property is because InnerHTML does not allow you to add <script> or <style> elements to an element, whereas the write() method does.If anyone can help I will be grateful.Thanks.Dooberry.
  17. dooberry

    CSS in XSL

    Right,That didn't change anything - but I have found the source of the problem.I am abusing the InnerHTML property of a table cell to show the output of an XSL transformation and the same problem is happening as happened when I tried to create script within the table cell using this method. There are certain elements which are part of the OuterHTML property and styles are one of them. When I try and set the InnerHTML for the cell it strips everything down to the <p /> tag and removes any styles that may have been set up.The easiest way round this will be for me to open a new window to display the output because I can then just use "document.write()" to show the result.I'll let you know if this works - thanks for your help, it's been a voyage of discovery!
  18. Hi - I saw this and noticed something that doesn't look right.In your style sheet I see you have put a few '=' signs where I would expect to see ':' (this is a bugger when you're switching between HTML and CSS). I could be wrong - but if you change these does it fix your problem?If not, have you checked that your printer drivers are up to date?
  19. dooberry

    CSS in XSL

    This is giving me a problem now. I can't get the template to work.I've used inline CSS in the template as I illustrated above, but the information is not being formatted by the XSL document.For example the XML reads: <contact><name>Contact Name</name><address1>address</address1><address2>address</address2><address3>address</address3><town>here</town></contact> The XSL reads: <xsl:template match="contact"><style type="text/css">p{font-weight: bold;font-style: italic}</style><p><xsl:value-of select="name" /><xsl:value-of select="address1" /><xsl:value-of select="address2" /><xsl:value-of select="address3" /><xsl:value-of select="town" /></p></xsl:template> Can anyone see anything wrong with this?Any help is appreciated.
  20. dooberry

    CSS in XSL

    That's a very useful tip. That means there's a lot less code to write (templates can be a git for that!) and I can just change one part of the code to reflect different styles on the content - in fact there could just be an element on each node to reflect the style that should be used to display it, but that's getting too adventurous for now.I think I need to learn a lot about the div element now because my document needs to be laid out in various sections (and tables get on my nerves! )Thanks for your help.
  21. dooberry

    CSS in XSL

    Hmm I like the sound of the Dynamic approach.What I was planning to do was embed a style within each node template so that when values are selected from different parts of the XML document, they are formatted according to the element they belong to.Taking an order as an example (I think everyone gets the order model these days): <xsl:template match="order"><html><style>p.orderdate{color: blue;font-size: 20}p.customer{color: green;font-size: 25}</style><p class="orderdate"> <xsl:value-of select="order_date" /></p><p class="customer"> <xsl:value-of select="customer" /></p></xsl:template> In this way, whenever there is an element of a particular type it appears in a particular layout/style on the page.This could be taken a step further into the Style template idea, but that's a bit beyond me at the moment (like you said - keep to the traditional stuff to begin with! ). I think this idea reflects one of the true intents of the <xsl:template> element - you treat nodes of the same type in the same way.D :) berry
  22. dooberry

    CSS in XSL

    Right then, I'm a complete noob on CSS and I get the whole inline, internal, external hierarchy thing.I'm planning to use CSS combined with XSL and XML to load up some data in a nice format so that it can be printed from the page.What I'm wondering is if I use the xsl:template element with it's own inline style, can I have multiple definitions for the same type of tag?I'm looking at using different font sizes, section widths and colors depending on the type of information (name of the XML element) that I'm looking at.Has anyone done this before and can you give me any pointers?Dooberry
  23. I think I was trying too hard!!I used that principle with <xsl:choose> instead of <xsl:if> and I can now pick between a default value and a user entry - that's all I was trying to do.Thanks for your help.Dooberry decides to buy a book called 'XSL for Dummies'.
  24. Ok, I did some rummaging around in the recommendations and found the URI to do the job: http://www.w3.org/TR/xpath-functions/Are the tutorial namespaces going to be changed, because this is a little confusing for simpletons like myself?
  25. Ok, I've got a more basic problem.The exists XPath function is not working. I'm using the following namespace declaration: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> But I get one of 2 errors, If is use "exists(nodename)" I get the error message 'exists is not a valid XPath function'.If I use "fn:exists(nodename)" I get the error message 'http://www.w3.org/2005/02/xpath-functions does not contain any functions'.Where am I going wrong?Dooberry
×
×
  • Create New...