Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Donar

  • Rank
  1. Good day, My XSLT transforms XLM pages into HTML pages. Now I am stuck with a problem, that seems not trivial to me. I would appreciate a pointer into the right direction. I want to reduce the number of lines I have to write in my original XML files. What I want, is something like a XSLT preprocessor, translating some XML tags into a group of other XML tags, before XSLT processes them. If at all possible, I want to keep the replaced as well as the replacing lines in the same XML document (so, no include-file-style solutions). Example: Oftentimes, my XML files contain repetitive multiple lines, e.g. the following simplified snippet: <img> <url>a_midi.jpg</url></img><img> <url>b_midi.jpg</url></img><img> <url>c_midi.jpg</url></img> It would be great, if I could include these multiple lines into a macro tag, placed somewhere near the beginning of the XML file, like this: <macro id="name_a"> <img> <url>a_midi.jpg</url> </img> <img> <url>b_midi.jpg</url> </img> <img> <url>c_midi.jpg</url> </img></macro> Instead of repeating the initial lines over and over again at various places, I'd just use something like: <use_macro id="name_a"/> Now, I certainly can instruct the XSLT to process the template <macro> matching the name "name_a", when it encounters the <use_macro> tag. However, this is not what I want. The reason is, that above <img> tags are themselves contained in another surrounding tag, say <multi_img>. The XSLT processing this <multi_img> tag considers a lot of other tags contained in itself, which dictate how exactly the XML is transformed into HTML (and sometimes the <img> tags even need to be processed multiple times in different manners.) Hence, what I am looking for, is a way to (1) first transform the XML <use_macro> into the XML contained in the <macro> tag; (2) and then process the resulting XML with XSLT as if there was no <use_macro> tag at all in the first place. Possibly the solution is obvious and I am just overworked, but I can't find what I need (even not after spending some time with Jeni Tennison's "XSLT and XPath / On the edge"). I appreciate pointers (also to the appropriate chapter in Tennison's book), or just the statement "it can not be done". Thanks in advance. Regards,Donar
  2. Donar


    Disregard. Thank you.
  3. I changed the original <script language="JavaScript"><xsl:comment> // code// </xsl:comment></script> to <script type="text/javascript"> // code</script> IE still processes the submit request, FF still does not process it.But the FF error console changed now to:"Error: document.forms is not a function"That's it, something changed, and you guided me to the right track right from the beginning, as I now acknowledge.Of couse, in this line: var children = document.forms(formid).childNodes; JS wants [...], not (...), even if recognized by IE.IE still works, FF not, but now it says:"Error: setting a property that has only a getter"The only possible line in question was: document.URL = url; Now even if supported by the IE, the official statement must be location.href = url; of course.And ya baby, it works in all browsers ("all" = IE, FF, Chrome, Opera). How can I thank you?Regards,Donar
  4. Yes, thank you. It just says that said function is not defined, and so it reacts.Are you using Mozilla Firefox? May I ask you to use Ctrl-A on the page and view the source code, please? It is very well possible that there is an error in my script (however, in that case the IE would not complain). (Viewing the source without marking anything will just show the raw XML).Now, the pure existence of that error tells, that we are "beyond XML", so to say, because XML would have no clue what <form> means and react at it like it would with <notunderstood>. So we are in the "HTML/JS view", in which a <form> has a defined meaning. Only that it won't do what it should.Well, that is *my* understanding of the things. Somewhere I am wrong, I feel this, but I still do not see it.In the meantime, thanks for your time, it's appreciated.
  5. Yes, thank you for your remarks. However, the form isn't being submitted at all (except in IE 8 and 9) - it reacts to a click as if the referenced function was not defined at all. But since the output generated by XSLT is presented to the client as pure HTML/Javascript (which can be verified in above ref [2]), one should assume that the function is there. Could it be that 3 known browsers are doing that wrong? I tend to search the error on my side. (Funny thing is, of course, that for once it works with cursed IE and not with the others.)Also, as I wrote: When I copy the output generated by XSLT (pure HTML/Javascript) to a new file, then all browsers work just fine.Regards,Donar
  6. Dear forum,My site uses XML pages. They are presented to the clients via XSLT.The server runs IIS 7.5. With the help of this forum and some Web research I added an ASP handler to be able to process ASP scripts.[see 1]Scripts can be processed now, and all works fine as it should, with one exception:I have encoded an XML form, which is presented to the client (via XSLT) as a HTML form.[see 2] Submitting this form (via submit button or javascript-executed button) does work only in IE 8 and IE 9, but not in Firefox, Chrome or Opera: the latter 3 all ignore the call.This is somewhat perplexing, because copying the whole presented HTML output into a test file with a html extension (as opposed to the original xml extension) and calling this html file shows absolutely no problems in Firefox etc.I understand that the problem is quite complex, given that it involves XML/XSLT, ASP scripting and Javascript. However, any pointer towards a solution, or at least towards problem isolation, would be highly appreciated.Thanks in advance,Donar[1] http://w3schools.invisionzone.com/index.php?showtopic=36758[2] http://www.gandraxa.com/solving_linear_rec...e_sequences.xml
  7. Thanks for directing me into the right direction.After a lot of research I came up with the following:First I tried to duplicate the entry for the .aspx entension in my site's web.config page. <system.web> <compilation> <buildProviders> <add extension=".xml" type="System.Web.Compilation.PageBuildProvider"/> </buildProviders> </compilation> </system.web> But this alone won't do the trick: everything behaves just like before:both static and dynamic .xml are served without being preprocessed at the server.However, adding this in the system.webServer section: <system.webServer> <handlers> <add name="ASPNETLikeHandler" path="*.xml" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" modules="ManagedPipelineHandler" requireAccess="Script" preCondition="integratedMode" /> </handlers> <validation validateIntegratedModeConfiguration="false" /> </system.webServer> eventually *does* the preprocessing! Only that the returned preprocessed page does not get recognized as an XML file anymore by the client's browser, which is a necessity in order to have it transformed with XSLT.Edit:The MIME type page contains for the xml entry: text/xml, but I suspect that this is not what is returned when the page is preprocessed, instead IIS delivers text/html (just a hypothesis). To overcome this, I need to tell the client browser that this is an XML file, which is done server-side by including this line of code at the second line of *all* XML pages: <?xml version="1.0" encoding="ISO-8859-1"?><% response.ContentType="text/xml" %> Thanks for your time.Regards,Donar
  8. Thanks for your answer. I agree with that one, of course.Anyway, does this mean that IIS just handles pages with an .aspx extension, and that there is no way on preprocessing a page's server-side scripts when there is another extension?Regards,Donar
  9. Thanks again for your answer, boen_robot.Well, it is XML content, so I really prefer the .xml extension, I don't like the idea of "pages in disguise" too much.However, I can not really believe, that IIS should not be able to process anything else than .aspx-pages; there surely must be a way to tell it which extensions to handle accordingly.Regards,Donar
  10. Dear Forum,Win 7 Ultimate, IIS 7.5 here.How can I have IIS preprocess my .xml pages before I send them to the client? Basically, I want to run my run-at-server scripts like with .aspx files, only that my pages have the .xml extension (and XML content of course).The approach taken so far:I expanded the path on the handler allocation page from old "*.aspx" to new "*.aspx, *.xml" for all three of:PageHandlerFactory-Integrated, PageHandlerFactory-ISAPI-2.0, and PageHandlerFactory-ISAPI-2.0-64.However, I seem to have not enough understanding on how IIS works, as it does not process an XML page containing<%@ Page Language="C#" %>in the first line, but sends it to the client (which correctly complains that this XML is not well-formed).Thanks in advance for your time.Regards,DonarEdit: If this is the wrong board for my help request, I'd appreciate a pointer to the correct one. Thank you.
  11. Thank you. It will be ASP then.RegardsDonar
  12. Good day forum.Can I (in XSLT 1) somehow obtain the HTTP query part of the actual XML page?Example:Suppose I have a page which was called with a query, e.g.:"http://example.com/page.xml?x1=1&x2=2&x3=3"Am I able to somehow obtain the name/value-pairs "x1"/"1" etc. with XSLT?Regards,DonarEdit: Fixed link.
  13. Donar

    Sorting uniquely

    Ordered "XSLT and XPath On The Edge" and looking forward to it.Thank you!
  14. Donar

    Sorting uniquely

    XSLT 1.0 it is.Thank you very much, it works for me. The final intention is to process an inner loop within the now possible outer loop:b:1a:2c:3a:4should givea:2, 4b:1c:3Then my inner loop looks like this:<xsl:for-each select="key('key', .)">and everything is absolutely fine.My 2 quite thick XML books did make no mention about generate-id() and key(), or even Muenchian grouping, so I did not know they existed (and hence had no idea about googling them). Can you recommend a good XSLT book (English or German)?Thanks again!
  15. Good day forum!There I am thinking I understood xsl:for-each and xsl:sort. A day later, after a zillion unsuccessful attempts I turn to you in search for help. Maybe you can help me with an approach I did not think of.I am looking to process an unsorted list having multiple identical keys into a sorted list, in which each key appears just once, or in other words, I want to eliminate all dupes, e.g.: <list><item><key>C</key>...</item><item><key>A</key>...</item><item><key>B</key>...</item><item><key>A</key>...</item></list> should transform to <list><item><key>A</key></item><item><key>B</key></item><item><key>C</key></item></list> (it does not matter which of the 2 "A" nodes is discarded.)Looking forward to your suggestions!Thanks in advance!
  • Create New...