|
Does it need to be done this way ? Anyhow, I do know that an XmlAttribute is a seperate item which you can create and append to the Attributes collection of the node.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hi All!
OK, here is architecture question:
My ultimate goal is: move "clent/server" application to web-site using XML/XSL. If user's browser is capable of processing XML/XSLT, processing should be performed on the cliend side, if not - on the server side.
That is a problem that I don't understand how to implement it:
1. I cannot let user access URL where it will be name like http://<something>/myform.xml for two reasons:
- I cannot process DB connection in that .xml file. Situation is: some users will access data using common DB name, some will access it using their very own DB name. As far as I understand, I cannot do that in .xml file, so I need some sort of .asp or jsp or something else.
- User's browser could be so old that it will not understand .xml extention. I don't know is it valid reason or not (I'm VERY new to web development).
2. So I need to let user access URL where it will be name like http://<something>/myform.asp or http://<something>/myform.jsp. That page will internally (depending on a user's browser) do one of this:
- either take my .xml page, process it with my .xsl page and send result .html to the user; OR
- take my .xml page and send it directly to user'sd browser. User's browser will see .xsl reference inside, automatically load that .xsl from my site,
and process both of them locally at client (I hope )
3. Now it is a problem. Suppose, user want to resort columns in the table (which he see on the screen). In case of old browser it is easy - link will "POST" form back to server, server will process .xml again and return .html to the user.
What if user uses new browser and I want it process it again locally? If user accessed URL http://<something>/myform.xml, than myform.xml would be sitting in cash on user's computer (together with .xsl), so I could call "load" method of XSLT locally in browser, so browser will not connect to server again.
But in my scenario user accesed http://<something>/myform.asp. If I will specify that name as parameter for "load" function, browser will go to server for new copy of the same data (which I'm trying to avoid). If I will specify http://<something>/myform.xml - such file does not exist locally, it exists with some other name (which I don't know).
So what could be a solution?
I'm sure it's obvious, I'm just overloaded with this new technic and cannot get it
Hope my description of a problem was clear .
SY-
Kosta.
|
|
|
|
|
Given that it looks like you do not have good control on the browser the client will be using, I would highly recommend only doing server side processing. I.E. keep it as you say easy with the POST. Even if you have some performance issue, Make it work right first with the extra database calls. Then you can take time to make it work better after you have some experience.
"I will find a new sig someday."
|
|
|
|
|
Hi Gurus!
I am a XML beginner. I am trying to create the xsl style sheet for the following XML document. I can't retrieve in XSL the value of attribute "Id" from the "Filter" node.
This XML and XSL must be viewed in the regular IE 5.0 without additional MSXML packs. Help me!
<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="2.xsl"?>
<TrafficReport>
<Filter Id="1">
<Name>TCP</Name>
<Sent>21122</Sent>
<Recv>4523487</Recv>
</Filter>
<Filter Id="2">
<Name>TCP 8080</Name>
<Sent>154953</Sent>
<Recv>7199212</Recv>
</Filter>
</TrafficReport>
2.xsl:
<?xml version="1.0"?>
<xsl:template xmlns:xsl="uri:xsl">
<HTML><BODY>
<table cellspacing="0" cellpadding="5" border="1">
<xsl:for-each select="TrafficReport/Filter">
<tr>
<td STYLE="font-family:Arial; font-size:12">
------Here is my problem <xsl:attribute name="Id"><xsl:value-of select="@Id"/></xsl:attribute>
</td>
<td STYLE="font-family:Arial; font-size:12">
<xsl:value-of select="Name"/>
</td>
<td STYLE="font-family:Arial; font-size:12">
<xsl:value-of select="Sent"/>
</td>
<td STYLE="font-family:Arial; font-size:12">
<xsl:value-of select="Recv"/>
</td>
</tr>
</xsl:for-each>
</table>
</BODY>
</HTML>
</xsl:template>
Yours sincerely,
Alex Bash
|
|
|
|
|
I think this is closer to what you are looking for
You have spelled trafficeReport with and without a capital T. Not the same element.
the xsl:attribute -> Generates an attribute in the destination document. I do not think you were creating a new attribute but just using the value of what you have.
http://www.vbxml.com/xsl/XSLTRef.asp is a fairly good online reference.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<HTML><body>
<table cellspacing="0" cellpadding="5" border="1">
<xsl:for-each select="trafficReport/Filter">
<tr>
<td STYLE="font-family:Arial; font-size:12">
<xsl:value-of select="@Id"/>
</td>
<td STYLE="font-family:Arial; font-size:12">
<xsl:value-of select="Name"/>
</td>
<td STYLE="font-family:Arial; font-size:12">
<xsl:value-of select="Sent"/>
</td>
<td STYLE="font-family:Arial; font-size:12">
<xsl:value-of select="Recv"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</HTML>
</xsl:template>
</xsl:stylesheet>
<b><i>"I will find a new sig someday."</i></b>
|
|
|
|
|
Hi All!
Basically all my question is in title: how to apply XSLT to XML on the server in JSP or ASP without DOM?
I have data.xml file and style.xsl file. If user access my page (either JSP or ASP or doesn't matter) with browser that supports _full_ XML + XSLT, than I just send to user file data.xml, user's browser processes it, finds reference to style.xlt, retrieves it and process both to the end result. If user uses outdated browser (no XML/XSLT or old versions), I do the same on the server.
Example of such script on server side:
<%
dim xmlMenu
dim xslMenu
'Get the source XML
set xmlMenu = server.CreateObject("Msxml2.DOMDocument.4.0")
xmlMenu.async = false
xmlMenu.load server.MapPath("data.xml")
'Get the XSLT to transform the XML
set xslMenu = server.CreateObject("Msxml2.DOMDocument.4.0")
xslMenu.async = false
xslMenu.load server.MapPath("style.xsl")
'Transform the source XML using XSLT
Response.Write xmlMenu.transformNode(xslMenu)
set xmlMenu = nothing
set xslMenu = nothing
%>
I want to have exactly the same but without DOM, because it takes a lot of memory (well, I personally didn't notice that. The above script processed 8MB file with 16,000+ nodes in 25 sec on my development PC (256MB Ram, P4 1.4, Personal Web Server + MSXML) to table-like HTML. But people say 4MB file takes > 100MB of RAM and is slow. May be they mean "stress testing"?).
I cannot use anything except ASP or JSP - no COM, C++, ActiveX or other stuff. Not that _I_ don't want to, but that's an in-house rules (((((
Thanks a lot for answer!
SY-
Kosta.
|
|
|
|
|
You want to apply XSL to XML, without an XSL parser of any kind ? How, exactly ? I don't think it's possible unless you write your own, and if your management insists you do it this way, I suggest you look for another job, and use the word 'morons' liberally in your resignation letter.
I'm sorry, I don't see how it can be done.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Well, I could use MSXML.
In fact, posted ASP script uses MSXML (I corrected my original question by adding some performance test numbers). But, if I right understand (may be I'm wrong here? - I'm complete novice with XML and ASP ), that script creates DOM object by calling "CreateObject" method. And I've seen posts in this forum that DOM is slow and takes a lot of memory. I found out that SAXON might be solution, but again - I cannot use any 3rd party software
I try to rephrase queastion - is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method?
And by the way - they are not morons. They are US government . Well, may be they are after all Tssss.
|
|
|
|
|
Kosta Cherry wrote:
Well, I could use MSXML.
MSXML is a COM object, it requires CreateObject and is based on the DOM.
Kosta Cherry wrote:
that script creates DOM object by calling "CreateObject" method.
Correct.
Kosta Cherry wrote:
And I've seen posts in this forum that DOM is slow and takes a lot of memory.
Every idiot has an opinion. Yes, DOM is bigger than SAX, but I don't see what option you have. I dunno if there are SAX XSL processors, but either way, you need a processor to do the processing.
Kosta Cherry wrote:
I try to rephrase queastion - is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method?
Yes, write one yourself in ASP.
Kosta Cherry wrote:
And by the way - they are not morons. They are US government
LOL - now THAT speaks for itself.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Kosta Cherry wrote:
And by the way - they are not morons. They are US government
Christian Graus wrote:
LOL - now THAT speaks for itself.
Yes, To be honest I do not think the US is unique. I do have experience working with the Australian government also.
"I will find a new sig someday."
|
|
|
|
|
Kosta Cherry wrote:
is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method?
Yes, Look at the Apache XML code XALAN http://xml.apache.org/. For large processing it does not require the resources for a DOM implementation. That is the real issue (IMO), if you are having to go to disk to handle a DOM implementation and not for a SAX. If you know you have the resources I find that DOM works just as well. A warning though, The processing can be different between the two. A XSL file for one will not always give the same results when applied to the other.
If that is not acceptable. MSXML does have a SAX implementation. See
http://www.perfectxml.com/msxmlSAX.asp
Kosta Cherry wrote:
I cannot use any 3rd party software .
I have always been intrigued by this statement. MSXML is not 3rd party but XALAN / Xerces is, but the Apache code I can down load and look through.
"I will find a new sig someday."
|
|
|
|
|
i would transfrom the xml - and output it to a text file or session variable.
then when you get a request check the date of the xslt & xml file - if either are new regenerate the output.
otherwise just return the file/session variable as the output.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
OK, I finally found answer (sort of) to my question and it is "SAX Parser with ASP" article at
http://www.experts-exchange.com/Web/Web_Languages/XML/Q_20150239.html
Here is copy of code from there (in case anyone interested):
<%Response.ContentType = "text/xml"
Dim generator, ch
' instantiate XML generator class
Set generator = Server.CreateObject("XMLFilesVBSAX.CGenerator")
Set ch = Server.CreateObject("XMLFilesVBSAX.CSerializer")
ch.RegisterOutputStream Response
generator.generateXML ch
%>
Then ->
<%Response.ContentType = "text/xml"
Dim reader, ch
' instantiate XMLReader class
Set reader = Server.CreateObject("MSXML2.VBSAXXMLReader.3.0")
' instantiate class that implements IVBSAXContentHandler
Set ch = Server.CreateObject("XMLFilesVBSAX.CSerializer")
ch.RegisterOutputStream Response
' turn off namespace prefixes
reader.putFeature "http://xml.org/sax/features/namespace-prefixes", False
' register ContentHandler implementation
Set reader.contentHandler = ch
' begin processing document
reader.parseURL "file://c:\temp\whatever.xml"
%>
And lastly ->
<%
Dim reader, ch
' instantiate XMLReader class
Set reader = Server.CreateObject("MSXML2.VBSAXXMLReader.3.0")
' instantiate class that implements IVBSAXContentHandler
Set ch = Server.CreateObject("XMLFilesVBSAX.CInvoice2HTML")
' turn off namespace prefixes
reader.putFeature "http://xml.org/sax/features/namespace-prefixes", False
' register ContentHandler implementation
Set reader.contentHandler = ch
' begin processing document
reader.parseURL "file://c:\temp\whatever.xml"
%>
Thanks for everybody!
|
|
|
|
|
Thanks for this info. I've never used SAX, and I did not know it could parse XSL. However, I note you've had to call 'CreateObject', I thought you were not allowed to ? :P
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I am not allowed to create my own objects, but I could call existing ones
As far as I understand, government want to have all their projects to be written in one - two languages, so they could get rid of contractors after project finished and hire some idiots fresh from college to support all this trash
|
|
|
|
|
Kosta Cherry wrote:
I am not allowed to create my own objects, but I could call existing ones
Fair enough. In that case, I don't understand why you could not use the DOM, although it's certainly the case that SAX is more lightweight. I'm glad you asked this, I will use SAX myself in future in places where I've used to DOM.
Kosta Cherry wrote:
As far as I understand, government want to have all their projects to be written in one - two languages, so they could get rid of contractors after project finished and hire some idiots fresh from college to support all this trash
*grin* I see. In that case, I can see why 'no C++' was a requirement.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hey Guys,
I've got an app that dumps some data as XML and I want to be able to use this data as the basis for a HTML report.
So, knowing nothing about XSL, can XSL do it for me? If so, can anyone give me some pointers about where to look?
Cheers
James
|
|
|
|
|
James Spibey wrote:
can XSL do it for me
Most definately, it is all just well formed text really.
Here is a good tut on it.[^]
Just remember it is all text and you won't go wrong. Don't get hung up on the buzz words sounding different.
Paul Watson Bluegrass Cape Town, South Africa Colin Davies wrote:
...can you imagine a John Simmons stalker !
|
|
|
|
|
Thanks for that paul. Got it up and running in less than 5 minutes.
Cheers
James
|
|
|
|
|
my hero.
but a vb link - oh the dark side of the force
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
but a vb link
LOL Well the site is called VBXML but what VB and XML have to do with each other I don't know. Anyway
Paul Watson Bluegrass Cape Town, South Africa Colin Davies wrote:
...can you imagine a John Simmons stalker !
|
|
|
|
|
Paul Watson wrote:
LOL Well the site is called VBXML but what VB and XML have to do with each other I don't know.
It is just marketing to make comfortable those who do not wish to think still come. http://www.topxml.com[^] also works to those who do think.
"I will find a new sig someday."
|
|
|
|
|
Am encountering the following problem.
in my xml doc, there is elment as such:
<COMMAND function="Write"><![CDATA[$:set:mode EG]]></COMMAND>
the corresponding autogen xml schema from VS.NET returned
<xs:element name="COMMAND" minOccurs="0" maxOccurs="unbounded" >
<xs:complexType>
<xs:attribute name="function" form="unqualified" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
my understanding is the CDATA tag is asking the xml parser to ignore what is enclosed by the CDATA tag. By the same token, i would think the xml schema should also ignore the element value of COMMAND.
well, I isolated the xml schema validation is failing at this point. How should the xml schema really be to handle CDATA?
thanks,
huikm
|
|
|
|
|
Our app transforms xml data with xsl into html.
I use &#160;&#xD;&#xA; (space, carriage return, line feed) to separate data on different lines that eventually is displayed on an excel spreadsheet. After each line is a square that is undesirable.
Can anyone please tell me how to get rid of this square or how to display a line feed without it?
Thanks,
Lilian
|
|
|
|
|
this is realted to either:
&nbap;* your character encoding in your xslt
* or the fact that excel is not recognising the line feed - try missing out the line feed.
hope this helps.
|
|
|
|
|