Skip to content

XML / XSL

Discussions on XML and related technologies

This category can be followed from the open social web via the handle xml-xsl@forum.codeproject.com

2.6k Topics 6.8k Posts
  • 0 Votes
    2 Posts
    0 Views
    S
    You've probably hit most of the reasons you might not want to use XML. Couple of other reasons to use XML - a) not having to write your own parsing code and b) XML files explicitly define the encoding they use. This design decision doesn't seem to be so important that you want to take too much effort over it. Using XML's a no-brainer, really, IMO. Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • Different XSD representation of an element.

    xml help question
    3
    0 Votes
    3 Posts
    0 Views
    C
    Oh. I see. Thanks for the info.
  • how to use select result in another select [modified]

    regex xml tutorial question
    4
    0 Votes
    4 Posts
    0 Views
    S
    An alternative solution without variables: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <xsl:for-each select="//Products/Item"> <tr> <td><xsl:value-of select="@ItemColor" /></td> <td><xsl:value-of select="//Desciptions/Color[@ColorName=current()/@ItemColor]/@ColorId"/></td> </tr> </xsl:for-each> </xsl:template> </xsl:stylesheet> current() retrieves the context node of the scope surrounding the select attribute, i.e. the node currently selected by the for-each element in this case. Here's another solution, using an XSLT key element. This approach is very useful when there's a large number of things to lookup in. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:key name="color-name-to-id" match="//Desciptions/Color/@ColorId" use="../@ColorName"/> <xsl:template match="/"> <xsl:for-each select="//Products/Item"> <tr> <td><xsl:value-of select="@ItemColor" /></td> <td><xsl:value-of select="key('color-name-to-id', @ItemColor)"/></td> </tr> </xsl:for-each> </xsl:template> </xsl:stylesheet> Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • Generating multiple files using XSLT 1.0

    csharp ai-coding xml question
    5
    0 Votes
    5 Posts
    0 Views
    S
    I remembered that there's an Exslt implementation for .NET[^] - you can use the exsl:document() support it contains[^]. Easier than trying to write your own... Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • XSL Sort

    algorithms xml
    2
    0 Votes
    2 Posts
    0 Views
    S
    If SortName is the name of an element, try something like this: <xsl:sort select="./\*\[name()=$SortName\]"/> [edit]Or if SortName is the name of an attribute, then use this: <xsl:sort select="./@\*\[name()=$SortName\]"/> [/edit] Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • Rss Implemetation

    question
    6
    0 Votes
    6 Posts
    0 Views
    K
    Thank u Mr.KKarthik2000. It is really helpful for me.Now only i get a clear concept of Rss.Thank u once again.I have no words to greet u.
  • desktop news ticker

    com xml tutorial announcement
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Running an exe file

    html sysadmin hardware question lounge
    3
    0 Votes
    3 Posts
    0 Views
    B
    Stuart Dootson wrote: Firstly - note the forum title "XML/XSL" - I don't think your query is entirely appropriate for this forum? It was imho the Closest site I could find to HTML Stuart Dootson wrote: Anyway - I would hope the answer is "you can't, no way, no how, without some helper software already installed on the PC" - sounds like a recipe for malware hell. Well, as I own all the PC's on which to use this, (and as I also own the CPP Code that I want to run) installing helper software is no problem. The Link was Usefull. Thanks, :) Bram van Kampen
  • Empty value is passed while reading value from an XML node

    xml help question
    7
    0 Votes
    7 Posts
    0 Views
    M
    Sorry Guys, I thank you for ur reply.I found the problem myself and sloved the issue.Below is code that i used previously where i faced the problem <xsl:for-each select="Customer//CustomerDetails"> <xsl:value-of select="DateTimeConverter:ToDateTimeFormat(Customer//CustomerDetails/DOB,'dd-MMM-yy')" /> </xsl:for-each> Inside the for-each loop value for the DOB parameter is reterived as empty. Then i solved the issue by using the msxsl function as shown below <xsl:value-of select="msxsl:format-date(DOB, 'MMM dd, yyyy')" /> Regards Mahesh.J
  • ForEach reading only the last node only

    xml question announcement
    3
    0 Votes
    3 Posts
    0 Views
    A
    Thanks, it works
  • Nested foreach loop Urgent

    xml regex help question announcement
    2
    0 Votes
    2 Posts
    0 Views
    S
    This XSLT <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <table> <xsl:for-each select="Compare/columnNames/column"> <tr> <xsl:variable name="ColName" select="na"></xsl:variable> <td> <xsl:value-of select="na"/> </td> <xsl:for-each select="///Compare/Hotels/Hotel"> <td> <xsl:value-of select="./*[name()=$ColName]"/> </td> </xsl:for-each> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> produces this HTML fragment - is that what you were after? <?xml version="1.0"?> <table> <tr> <td>Name</td> <td>Hotel Mount View</td> <td>Hotel Mayur</td> </tr> <tr> <td>Address</td> <td>123</td> <td>Adress1</td> </tr> <tr> <td>Phone</td> <td>1234</td> <td>12345678</td> </tr> </table> Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • 0 Votes
    2 Posts
    0 Views
    S
    Can I suggest you select the 'Encode HTML tags when pasting' tickbox when pasting XML code into a post - most of your content has disappeared! Also, it helps to put it in a code block, using the 'code block' link below when the code is selected. Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • xml menubar

    tutorial xml question
    4
    0 Votes
    4 Posts
    0 Views
    S
    :thumbsup: :) Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • Use same objects to access DB and WebService

    database com
    2
    0 Votes
    2 Posts
    0 Views
    L
    .
  • [Message Deleted]

    4
    0 Votes
    4 Posts
    0 Views
    L
    lostinxsl wrote: I cant figure out this : a XSL generates a javascript function. Ok, that part is done then and has nothing to do with: lostinxsl wrote: This javascript functions is used in html . how can i do this ? Again, if you don't understand how to use javascript in a browser then you need to be studying more beginner material on that subject until you do understand. Also: lostinxsl wrote: I am only able to display the javascript function on a webpage Javascript that is correctly added to HTML will not be displayed in the browser. So again, you need to know how to write HTML/Javascript before you try to generate it with anything else like XSLT.
  • XML Accuracy Puzzle

    xml help regex architecture question
    4
    0 Votes
    4 Posts
    0 Views
    S
    contactowen wrote: On another forum (I know naughty) Indeed - consider your CP membership revoked!!! :-D contactowen wrote: With XSLT 1.0 you can use format-number to ensure you get a certain number of decimal positions. Quite true - I wasn't aware of that function until you mentioned it :-O contactowen wrote: Or you need to change to XPath 2.0 (as implemented by Saxon 9) and use xs:decimal numbers instead of double numbers. Also true (in the commercial version of Saxon, anyway - I don't think the free one supports XML Schema datatypes) - I presumed that you would be using MSXML, in which case XPath 2.0 and XSLT 2.0 aren't really an option. Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • Specifying condition with count function

    xml tutorial ai-coding question
    3
    0 Votes
    3 Posts
    0 Views
    F
    Thank you very much Stuart.. It really worked... Hats off to u
  • Image in XML attribute

    xml help
    2
    0 Votes
    2 Posts
    0 Views
    S
    Firstly you need to convert your image to base64 - I'll presume you know how to do this. To insert the new value, you need to navigate to the relevant element using the XML DOM[^] API. Then (presuming you're using Microsoft's MSXML) you would use the IXMLDOMElement::setAttribute[^] method with a name of "image" and the value set to the base64 encoded image string. Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
  • XML DOM insertBefore() Method

    html xml help
    2
    0 Votes
    2 Posts
    0 Views
    G
    You need to import the node, XmlNode XmlDocument.ImportNode(XmlNode, bool), first. "We make a living by what we get, we make a life by what we give." --Winston Churchill
  • XML/XSL Html table trouble

    xml html wpf regex help
    3
    0 Votes
    3 Posts
    0 Views
    S
    This is how I'd tend to write it - differences are: I've used CSS, rather than inline styles - my preference I've used the thead element for the header I've split up the templates a bit more - if you had more than one report-item-definition in an XML file, that would be useful :-) Also, it makes the context node more obvious, so you don't get issues like the one you had that George pointed out previously. I've used <xsl:apply-templates select="argument"/> rather than <xsl:for-each select="..."> to output each row of the table. My feeling is that using apply-templates like this is probably better idiomatic XSL than using for-each <?xml version="1.0" ?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match ="/"> <html> <style> th { text-align: center } thead { background-color: #cccccc } h1 { text-align: center; font-weight: bold } </style> <head> <title>XML Stylesheet</title> </head> <body> <xsl:apply-templates select="report-item-definition"/> </body> </html> </xsl:template> <xsl:template match="report-item-definition"> <h1><xsl:value-of select="item-title" /></h1> <xsl:apply-templates select="arguments"/> </xsl:template> <xsl:template match="arguments"> <table width="700" border="1" align="center" style="font-family:verdana font-size:10pt"> <thead> <tr> <th width="130"><b>Name</b></th> <th><b>Type</b></th> <th><b>Default</b></th> <th><b>Display Name</b></th> <th><b>Description</b></th> <th><b>Visible</b></th> <th><b>Filter Type</b></th> </tr> </thead> <xsl:apply-templates select="argument"/> </table> </xsl:template> <xsl:template match="argument"> <tr> <td><xsl:value-of select="name" /></td> <!