JSP, XML, XSLT: applying XSL on JSP-generated XML doc
Hello,
I am currently trying to figure out how to do the following:
let's consider (that's not entirely hypothetical :) ) a web application working with JSP (on apache/tomcat 3.1) and oracle BC4J Application modules.
The JSPs call oracle webbeans to perform updates and retrieve data from an 8.1.6 database.
Now I'm thinking of moving to a combination of JSP, XML and XSL, which (hopefully) would allow to customize the application depending on the user's browser, language etc...(that's the point isn't it?)
It doesn't seem to be a problem to produce XML from a jsp, send it directly to the client browser, which in turn goes to look for the proper XSL file and does all the transformation stuff.
However this only works with I.E 5 for the moment right? and most website need to support various kinds of browsers...
The need is:
* When a non XML-capable browser is detected, apply the proper XSL(s) on the server side before sending the result back, in html/wml/whatever...
* For XML-capable browsers, produce raw XML, maybe apply some XSL(s), and eventually send the result to the browser which handles the rest of the XSL stuff itself.
Therefore, I'd like to:
- Have the jsp produce the raw xml data (maybe adding extra tags, to indicate the browser and/or the language that the jsp engine has detected).
- Pass the output to a first XSLT engine which would take care of the language stuff
- Feed the result into a second XSLT engine to handle browser specificities for instance...
- Send the final output to the client browser.
Now, there are 2 problems:
* 1/ I have seen various engines capable of chaining XSL transforms, and it is easy to produce XML from a jsp, but I don't know how to feed a jsp's output into an XML engine. is that possible? how?
* 2/ I'm a bit concerned about the cost of applying three (or more) process stages, does anyone have insight on the performance issues this could raise?
bonus question ;) : is there a simpler approach?
Thanks a lot in advance, Remi
null
Hello,
I am currently trying to figure out how to do the following:
let's consider (that's not entirely hypothetical :) ) a web application working with JSP (on apache/tomcat 3.1) and oracle BC4J Application modules.
The JSPs call oracle webbeans to perform updates and retrieve data from an 8.1.6 database.
Now I'm thinking of moving to a combination of JSP, XML and XSL, which (hopefully) would allow to customize the application depending on the user's browser, language etc...(that's the point isn't it?)
It doesn't seem to be a problem to produce XML from a jsp, send it directly to the client browser, which in turn goes to look for the proper XSL file and does all the transformation stuff.
However this only works with I.E 5 for the moment right? and most website need to support various kinds of browsers...
The need is:
* When a non XML-capable browser is detected, apply the proper XSL(s) on the server side before sending the result back, in html/wml/whatever...
* For XML-capable browsers, produce raw XML, maybe apply some XSL(s), and eventually send the result to the browser which handles the rest of the XSL stuff itself.
Therefore, I'd like to:
- Have the jsp produce the raw xml data (maybe adding extra tags, to indicate the browser and/or the language that the jsp engine has detected).
- Pass the output to a first XSLT engine which would take care of the language stuff
- Feed the result into a second XSLT engine to handle browser specificities for instance...
- Send the final output to the client browser.
Now, there are 2 problems:
* 1/ I have seen various engines capable of chaining XSL transforms, and it is easy to produce XML from a jsp, but I don't know how to feed a jsp's output into an XML engine. is that possible? how?
* 2/ I'm a bit concerned about the cost of applying three (or more) process stages, does anyone have insight on the performance issues this could raise?
bonus question ;) : is there a simpler approach?
Thanks a lot in advance, Remi
null
Similar Messages
-
Imported XSLT cannot create attributes for generated XML element
I have two xslts. One imports the other.
The imported xslt creates XML elements with attributes and this XML is stored in a variable in the main stylesheet
If I perform the transformation with JRE prior to 1.6.0.18 then all works fine
If I use 1.6.0.18 or 1.6.0.19 then the attributes aren't added.
If I add attributes in the main xslt it works fine or if I output the element directly instead of first storing it in a variable then it also works fine.
Problem seems to be when you try to add attributes from an imported stylesheet and store the generated element in a variable.
Below two stylesheets to illustrate :
First MainStylesheet.xsl
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 1993-2005 Seagull Software Systems, Inc. -->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
exclude-result-prefixes="xs">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
<xsl:import href="innerstylesheet.xsl"/>
<xsl:template match="/TestData">
<xsl:variable name="generatedElementXml">
<xsl:call-template name="generateElement">
<xsl:with-param name="s">testValue</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="exsl:node-set($generatedElementXml)">
*** GeneratedElementXML {<xsl:text>
</xsl:text><xsl:copy-of select="*"></xsl:copy-of>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>Next innerstylesheet.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:exsl="http://exslt.org/common"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
extension-element-prefixes="exsl" >
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:template name="generateElement">
<xsl:param name="s"/>
<TestElement testAttribute="$s" />
</xsl:template>
</xsl:stylesheet>The result output by jres before 1.6.0.18 is :
<?xml version="1.0" encoding="UTF-8"?>
*** GeneratedElementXML {
<TestElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" testAttribute="testValue"/>
} The result output by jres since 1.6.0.18 is :
<?xml version="1.0" encoding="UTF-8"?>
*** GeneratedElementXML {
<TestElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
} Note : the 'testAttribute' attribute is missingHave found the difference in the code
In both JRE1.6.0_17 & JRE1.6.0_18, the class 'com.sun.org.apache.xalan.internal.xsltc.dom.AdaptiveResultTreeImpl' has the following method
public void addUniqueAttribute(String qName, String value, int flags)
throws SAXException
addAttribute(qName, value);
}In JRE1.6.0_17 the next method is
public void addAttribute(String name, String value)
if (_openElementName != null) {
_attributes.add(name, value);
else {
BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, name);
}In JRE1.6.0_18 the next method is
public void addAttribute(String uri, String localName, String qname,
String type, String value)
if (_openElementName != null) {
_attributes.addAttribute(uri, localName, qname, type, value);
else {
BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, qname);
}Note - the addAttribute method has additional parameters in JRE1.6.0_18 but the call from addUniqueAttribute wasn't updated.
So in JRE1.6.0_18 addUniqueAttribute actually invokes the following method in the base package com.sun.org.apache.xml.internal.serializer.EmptySerializer
public void addAttribute(String name, String value)
aMethodIsCalled();
void aMethodIsCalled()
// throw new RuntimeException(err);
return;
}and as you can see this does nothing. Hence the fact that the attribute isn't added. -
XML/XSLT: Setting xsl:include href attribute with a variable
I have a main layout stylesheet and depending on which page the user selects I want to use xsl:include to display the selected information in the 'content' DIV. The process works fine if hardcode it like this:
<xsl:include href="welcome.xsl"/>
<div id="content"
<xsl:call-template name="welcome"/>
</div>
but, what I would like to do is have the name of the included template pulled from the xml file depending on which page was selected by the user. Something similar to this:
<xsl:variable name="ss">
<xsl:text><xsl:value-of select="root/stylesheet"/></xsl:text>
</xsl:variable>
<xsl:include href="{$ss}.xsl"/>
<div id="content">
<xsl:apply-template name="{$ss}"/>
</div>
So far I have tried using many different forms of code and have been unable to get this to work. Any ideas?
EDIT: Okay, I have it partly figured out, at least why it isn't working. As far as I can tell, the 'xsl:include' tag must be a child of the 'xsl:stylesheet' tag, and is thus declared before the <xsl:template match="/"> which means it can't read the xml element to even store it in the variable. I have an idea of how to accomplish what I need, though.
Last edited by munkyeetr (2009-01-28 03:29:58)I have attempted the same thing before as well. The only way I was able to dynamically build the xsl:include was to declare a new namespace e.g xmlns:out="output.xsl" in my XSL file and do something like the following:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:out="output.xsl">
<xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
<xsl:varible name="xxx" select=" 'myFile.xsl' "/>
<xsl:template match="/">
<out:stylesheet version="1.0">
<out:template match="/">
<out:include>
<xsl:attribute name="href">
<xsl:value-of select="$xxx" />
</xsl:attribute>
</out:include>
</out:template>
</out:stylesheet>
</xsl:template>
</xsl:stylesheet>
When applied to any valid XML document this produces the XSL file you are after as the output.
To use this output against your intended XML source consider the following: A Java program can very quickly apply the above stylesheet to any XML source to get the output you want... then apply that XSL result to the actual XML document you are wanting to transform. From here you can do what you want with the transformed result. -
Hi all!
I'm in a bit of a dilema. As the least knowledgable member of our small development group (3 people incl. me) I'm caught in the middle of a pretty fierce debate over whether or not to we should implement JSP.
Currently to seperate business logic from presentation we have our servlets pass XML to the browser and then the browser renders the HTML using the appropriate .xsl (sometimes we use server-side transformation).
Now one of the guys wants to use MVC/Struts and JSPs in order to create a much needed UI for an application. The plan is to not put any Java code in the JSP (seperation of logic and presentation - good, business logic in both the JSP and Servlet - bad.) but the other guy is still vehemently against it.
He says that anything JSP can do we can already do with XML/XSLT and to add JSP to our environment would complicate things.
And while I agree with him there, there are some things that when you do them with JSPs make the code more readable and transparent.
If you had to take a side, which one would you choose?
Has anyone else out there already gone through this debate? I'd be interested in knowing the outcome.
Thanks,
JohnI have a couple of comments.
1> "XML to the browser and then the browser renders the HTML using the appropriate .xsl"
I all cases you should do the transformations on the server. Lot of browser do not know how to
do a xsl transform. And since you can do it some time why not do it not everytime?
2> "business logic in both the JSP and Servlet"
Business logic should neither be in servlets nor in jsp. I think they should be in business logic beans.
3> "anything JSP can do we can already do with XML/XSLT "
Although anything can be done using xml/xsl or jsp there are a bit of differences where struts-jsp architecture is more perferable.
Imaging a web site which has lots of online forms(with textfiedls, checkboxes, select lists, etc) which are to be validated and if some validation fails the same form is to be shown with the values already submitted prefilled. Doing this with xml/xsl or even simple jsp could be a nightmare.
But if you use struts MVC architecture with jsp and struts taglib this will be very very simple.
Introducing struts-jsp will not complicate things and if the scnario described above is there or could arise in your application then you should seriously think about using struts+jsp. That does not mean you will have to scrap you xml+xsl architecture. You can still generate the xml using your action bean , put the xml in request and forward it to you jsp for rendetion. The jsp page could then use a taglib which has the xsl transformation code to do the xslt transformation.
The above comments are not just my thoughts but i have also implemented/experienced the above during various projects and they have proved to be useful.
Cheers! -
My company are sending reports to out customers by translating XML with an XSL file to generate a HTML file and then emailing it to our customers.
At the moment we are using XALAN to process the XML through the Style Sheet.
We would like to shift the processing onto our users by letting their browsers do the work.
We cannot send the xml and xsl as 2 seperate files because the users would have to extract both files into the same location then open the XML.
Is it possible to use embed XSL in XML for use in MS Internet Explorer???????
I heard that not all translators support embedded XSL but I cant find any info on mdsn.
Any help would be appreciatedFirst, you are assuming that your customers are using Internet Explorer. If this is not the case, then your plan will fail.
Second, Internet Explorer (in its current standard configuration) does not run XSLT as known to Xalan, but another similar, obsolete, non-standard language (called XSL by Microsoft). IE can be made to work with standard XSLT, by installing a special DLL.
So you can do this if you like, but first you need to get more knowledge about the IE implementations of XSL (it is on MSDN!) and then you will need ongoing support for customers who need help configuring their browsers.
As you can probably guess, I think your server-based scheme is a much better idea. -
I'm a total newbie in XML DB and need advice on generating XML from database.
The situation is the following: there is a legacy web application which uses an XML document as a configuration file. This document conforms to some well-defined schema. For instance:
<config>
<title value="TITLE" />
<subtitle value="SUBTITLE" />
<style url="default.css" />
<widgets>
<widget id="1" opened="true" />
<widget id="2" opened="false" />
</widgets>
</config>
It contains portions of static data which are common for all users as well as dynamic personal data.
Dynamic data comes from two sources:
1) security considerations (for instance, not all widgets are available for some users) - thus the "master" configuration content must be filtered, but not otherwise modified;
2) user preferences (for instance, user can set widget2 to be opened by default) - thus values of some attributes must be different for each user. When the user saves her preferences, the entire document with new values is posted back to server.
We want to try to store user preferences, apply security and generate personalized configuration documents using XML DB.
So we need advice on storage models and generation procedures - which should be more efficient and easy to support or extend.
Please note, that there is no requirement to actually store data as XML.
Thanks in advance!
P.S.: Sorry for the incomplete initial post.
Edited by: WxD on 27.09.2010 11:45Hi,
See this link for more details
http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10790/xdb13gen.htm -
XSLT, using document() to fetch a local JSP generated XML file
All,
I have 1 XML document that keeps track of various subsite owners of a domain I manage. The xml file doesn't hold much, something along the lines of:
<?xml version="1.0"?>
<sitedirectory>
<page id="/marys_page" name="Mary's Page"">
<content_contact ntid="smithm" />
<technical_contact ntid="techguy" />
</page>
</sitedirectory>Now I also have a JSP page, that when given an NT id as a URL parameter, rifles through LDAP and spits out an xml document with all the relavent ISID fields for that person's id (first name, last name, phone number, e-mail address etc).
I use the document() function in an XSL file to access that dynamic JSP page, fetch the contents of the resulting XML file. Using the document() function with just a regular file call like "getldap.jsp" only feeds my stylesheet the source of that JSP file, not the resulting XML file that I'm looking for when it's been processed.
So... I have my document() function calling the full URL to that JSP file on my domain, an example <value-of /> call in my XSL file would be:
<xsl:value-of select="document('http://my.domain.com/jsp_util/ldap_person.jsp?ntid=smithm')/person/firstname" />and I get what I want, that person's first name, drawn from LDAP into my XSL file. But it seems a little weird to me, having a server-side transformation, accessing a JSP file by making an http call to the same server the transformation resides in.
Am I missing something? Is there a better way to do this or some directive I'm missing? I'd appreciate any help.That's a creative but perfectly reasonable way to use the document() function.
There are other ways to solve the problem, such as including Java calls in your XSL and applying a customized URIResolver to your transformation, but my approach would be to use the simplest method that works acceptably. So if you don't have performance problems with your solution, I would leave it alone. -
HELP: JSP + XML + XSLT = HTML?
Hello, all.
I am trying out Weblogic 6 and I am trying to get the JSP + XML + XSLT =>
HTML chain working.
I am coming from using Orion and SAXON.. and in that situation I had a JSP
that contained XML tags... they were filled in at runtime and then using
Servlet-Chaining was passed along to the SAXON XSLT Processer. SAXON checked
for the inline XSL specified and then used that to transform the document
into HTML.
It worked well, but there were some other features missing/not documented
that we now need.
With Weblogic I am trying to use the XSLT Tag Library that comes with the
distribution, but it seems to be very finicky. I followed the directions and
I got it to do a sort of roundabout transformation. But it doesn't seem to
work quite right.
The best I can get is the following:
I have an 'xslt' directory url-pattern-mapped to xslt.jsp (as instructed)...
but can't figure out how to specify the xsl file on-the-fly... that is, if I
don't hard-code the XSL file in the x:xslt element in the xslt.jsp it
complains about some XML file not having a root element.
Ideal situation:
1. I have a JSP that includes XML elements.
2. It is filled from a database at runtime and specifys (using a PI) what
XSL stylesheet it is to be processed with.
3. Somehow (fingers crossed) the XML is processed and transformed into HTML
by the appropriate XSL file.
I think I am mostly stuck moving between steps 2 and 3.
Can anyone give me some hints? Are there some Weblogic specific
elements/tags that I have to include in the XML file that Weblogic will
catch and re-direct to the XSL Parser?
Please, anyone, if you have some information, I would much appreciate it.
Dylan Parker
PS - I apologize for the cross-post, I hope it doesn't cause too much
traffic.Craig,
I've since discovered how to do it with the WL Taglibrary... and have
moved on =)
It has to do with the EXTREMELY BADLY documented x:xml tag that can
appear within the x:xslt tag body...
So the WL Tag Library allows something like the following.
(Please note, angled brackets are omitted in this post to prevent html
parsing)
[x:xslt stylesheet="sheet.xsl"]
[x:xml]
Here is the XML to run the sheet on.
This should have all relevant XML syntax: the PIs, the doctype,
root elements etc...
[x:xml]
[x:xslt]
And that DOES work. But not very well. WL, a little prematurely
incorporated versions 1.2 of Xerces and Xalan in their product -- and
these versions have some irritating bugs.
Also -- There tag library doesn't copy the source XML across as UTF-8
.. so a lot of the Japanese I have embedded there (from a DB) gets
mangled somewhere in their code...
AND -- If you hammer a little bit on an JSP/XML that uses the WL Tag
Library (eg clicking refresh lots of times in IE)... I get huge
amounts of irritating exceptions appearing in the log files.
NullPointerExceptions
XSL Parsing Exceptions
XML Parsing Exceptions
but completely unpredictably...
In my eyes.. the WL XML/XSL Tag Library using the incorporated and
untouchable Xalan and Xerces (v1.2) is virtually unusable.
What a pain.
BUT! Apache offers a similar OPEN SOURCE XSL Tag Library available
here:
http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html
And it uses the standard, non-weblogic-incorporated, Xerces and Xalan
(which means you can provide whatever version you want).. and it works
impressively well.
It has almost identical performance as the WL Taglib, and without all
of the bizarre exceptions being thrown.
And it does proper passing of the character encoding type!
If only the taglib did caching though =(
The performance hit over pure JSP is huge. Almost two orders of
magnitude. On my desktop box I can get around 500Requests/Sec if I am
returning HTML direct from a JSP... while if I produce XML that gets
processed by XSL into HTML the Requests/Sec drops to 5!!!!
Caching. Caching. And more Caching. A lot of DiskIO is going on with
the XML/XSL/XHTML chain of events.
I hope this helps!
I'd be curious as to what you find out as well.
Dylan Parker
On 5 Mar 2001 07:20:00 -0800, "Craig Macha"
<[email protected]> wrote:
>
Yep, I feel Dylan's pain.
I am trying to accomplish the same thing. A JSP page generating
dynamic XML content and then utilizing an XSLT stylesheet to transform
all the content into XHTML.
Does anyone have some examples that show exactly how to accomplish
this? Can I do this with WLS and the XML taglib that comes with
it? Or do I have to move on to something like Cocoon to get this
capability?
Any insight would be greatly appreciated.
Thanks,
Craig Macha
"Dylan Parker" <[email protected]> wrote:
Hello, all.
I am trying out Weblogic 6 and I am trying to get the
JSP + XML + XSLT =>
HTML chain working.
I am coming from using Orion and SAXON.. and in that situation
I had a JSP
that contained XML tags... they were filled in at runtime
and then using
Servlet-Chaining was passed along to the SAXON XSLT Processer.
SAXON checked
for the inline XSL specified and then used that to transform
the document
into HTML.
It worked well, but there were some other features missing/not
documented
that we now need.
With Weblogic I am trying to use the XSLT Tag Library
that comes with the
distribution, but it seems to be very finicky. I followed
the directions and
I got it to do a sort of roundabout transformation. But
it doesn't seem to
work quite right.
The best I can get is the following:
I have an 'xslt' directory url-pattern-mapped to xslt.jsp
(as instructed)...
but can't figure out how to specify the xsl file on-the-fly...
that is, if I
don't hard-code the XSL file in the x:xslt element in
the xslt.jsp it
complains about some XML file not having a root element.
Ideal situation:
1. I have a JSP that includes XML elements.
2. It is filled from a database at runtime and specifys
(using a PI) what
XSL stylesheet it is to be processed with.
3. Somehow (fingers crossed) the XML is processed and
transformed into HTML
by the appropriate XSL file.
I think I am mostly stuck moving between steps 2 and 3.
Can anyone give me some hints? Are there some Weblogic
specific
elements/tags that I have to include in the XML file that
Weblogic will
catch and re-direct to the XSL Parser?
Please, anyone, if you have some information, I would
much appreciate it.
Dylan Parker
PS - I apologize for the cross-post, I hope it doesn't
cause too much
traffic. -
I have a couple of jsp pages that generate xml formated data as well as xsl file. On win2k Ie everything works fine. On Netscape information comes up unformatted. I opened view source and saved it as separated xml file. When I open this xml file, information displayed with correct formatting.
Any suggestions will be greatly appreciated.
I use Tomcat 4.1 and java 1.4I solved it by setting response.setContentType( "text\xml" ); on my jsps.
Hope this will help.
PS The problem I still see in IE 5.2 ( MAC OS X ), Camillon browsers. However, I have the luxury of requesting internal clients to upgrade to latest versions. -
Using a data file in jsp to generate xml file
hi
can anybody help me to
how to use a data file generated in unix in jsp to generate xml file.
by using beans i am able to generate the xml.
thanks in advance.You haven't provided adequate relevant information. If you need help provide proper relevant details.
-
I used this code to create an xml file through an xsl:
<%@page import="javax.xml.transform.*,javax.xml.transform.stream.*,java.io.File,java.util.Properties" %>
<%
File fXml = new File("C:\\file.xml");
File fXsl = new File("C:\\file.xsl");
File fRes = new File("C:\\res.xml");
StreamSource xml = new StreamSource(fXml);
StreamSource xsl = new StreamSource(fXsl);
StreamResult res = new StreamResult(fRes);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(xsl);
transformer.transform(xml,res);
%>
but in the res.xml file i have:
<table> instead of <table>
what can i do to solve this problem?
thanksI'm near to solution
i use
StringWriter resultStringWriter = new StringWriter();
StreamResult res = new StreamResult(resultStringWriter);
and then
transformer.transform(xml,res);
String str = resultStringWriter.toString();
this is my xsl:
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="yes" encoding="ISO-8859-1"/>
<xsl:template match="XMLDATA">
<![CDATA[<tag1>]]><xsl:value-of select="CodiceAmministrazione"/><![CDATA[</tag1>]]>
</xsl:template>
</xsl:stylesheet>
but now the problem is the output:
\r\n<tag1>Test</tag1>\r\n
and not
<tag1>Test</tag1>
If I write the xsl on one line i have no problem
Can you help me please? -
Passing parameters from jsp to xslt
Hi all,
I am trying to pass a variable string from a jsp to xslt .
This is the code in the jsp which passes the variables .
<c:set var="xsl">
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="<%= "service_attribute.xsl" %>"/>
<xsl:variable name="ItemId"><%= ItemId %></xsl:variable>
<xsl:variable name="pos"><%= pos %></xsl:variable>
<xsl:variable name="lineInfoTn"><%= lineInfoTn %></xsl:variable>
</xsl:stylesheet>
</c:set>
<x:transform xmlSystemId="foo.xml" xslt="${xsl}">
<%= FM.getOrderBean().getXml("ActivationRequest") %>
</x:transform>
In the service_attribute.xsl I would like to be able to check the lineInfoTn variable for content .
something like this .
<xsl:if test="$lineInfoTn='10pt'">
<!-- Do something -->
<xsl:value-of select="$lineInfoTn"/>
</xsl:if>
The first problem is that it complains that the $lineInfoTn is not declared .
So I added the variable as a global variable .
<xsl:param name="lineInfoTn">10pt</xsl:param>
Note I have been switching between variables and parameters to try and get this working .
I can use the itemId variable like this and I dont have a problem .
<xsl:for-each select="q:RequestItem/q:ItemId[text() = $ItemId]/..">
Any ideas on how to get this working .
Thanks for your helpThanks for the input
-
I want to generate my JSPs using XSLT. We have many pages that have very similar layout, just different content. Therefore, I would like to create a XSLT stylesheet that contains JSP tags, so that I can use XSLT to generate the actual JSP. However, the 1.0 tags are not well-formed XML.
I have tried using the JSP XML elements described in Section 7.6 of the JSP 1.1 spec. However, I do not understand section 7.6.2. My non-XML JSP fragment looked like this:
<input
type="hidden"
name="<%= myName %>"
value="<%= myValue %>">
Does 7.6.2 really mean to convert it to:
<input
type="hidden"
name="%= myName '%"
value="%= myValue '%">
It seems odd.
Has anyone ever tried to generate JSPs using XSLT? If so, I would be interested in your experience with it.We are currently converting XML content into JSP through the XML Transformation process. In the XML document we wrap <jsp:root> and include attributes in the jsp:root element for the namespaces. We run through the transformation process and convert the document to a .jsp
-
ABAP Program that generates XML and calls an XSLT transformation,
Hello,
I am creating a program that creates some XML output, and I am using STRANS to create a transformation.
The file created looks like below before transformation.
<?xml version="1.0" encoding="utf-8" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
- <asx:values>
- <EMPLOYEE_DATA>
- <item>
<EMPLOYEE_ID>00000010</EMPLOYEE_ID>
<FIRSTNAME>Joe</FIRSTNAME>
<SURNAME>Bloggs</SURNAME>
<DOB>1940-11-10</DOB>
<SALARY>200000.0</SALARY>
</item>
<item>
<EMPLOYEE_ID>00000055</EMPLOYEE_ID>
<FIRSTNAME>Lydia</FIRSTNAME>
<SURNAME>Jones</SURNAME>
<DOB>1965-03-09</DOB>
<SALARY>90000.0</SALARY>
</item>
</EMPLOYEE_DATA>
</asx:values>
</asx:abap>
I want to make EMPLOYEE_ID an attribute like in the following
and what I want to output is:
<?xml version="1.0" encoding="utf-8" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml">
- <asx:values>
- <EMPLOYEE_DATA>
- <EMPLOYEE_DETAILS EMPLOYEE_ID="00000010">
<FIRSTNAME>Joe</FIRSTNAME>
<SURNAME>Bloggs</SURNAME>
<DOB>1940-11-10</DOB>
<SALARY>200000.0</SALARY>
</EMPLOYEE_DETAILS>
<EMPLOYEE_DETAILS EMPLOYEE_ID="00000055">
<FIRSTNAME>Lydia</FIRSTNAME>
<SURNAME>Jones</SURNAME>
<DOB>1965-03-09</DOB>
<SALARY>90000.0</SALARY>
</EMPLOYEE_DETAILS>
</EMPLOYEE_DATA>
</asx:values>
</asx:abap>
the XSLT I have cureently produces:
<?xml version="1.0" encoding="utf-8" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml">
- <asx:values>
- <EMPLOYEE_DATA>
- <EMPLOYEE_DETAILS EMPLOYEE_ID="00000010">
<EMPLOYEE_ID>00000010</EMPLOYEE_ID>
<FIRSTNAME>Joe</FIRSTNAME>
<SURNAME>Bloggs</SURNAME>
<DOB>1940-11-10</DOB>
<SALARY>200000.0</SALARY>
</EMPLOYEE_DETAILS>
- <EMPLOYEE_DETAILS EMPLOYEE_ID="00000038">
<EMPLOYEE_ID>00000038</EMPLOYEE_ID>
<FIRSTNAME>Fred</FIRSTNAME>
<SURNAME>Johnson</SURNAME>
<DOB>1960-12-11</DOB>
<SALARY>123450.0</SALARY>
</EMPLOYEE_DETAILS>
- <EMPLOYEE_DETAILS EMPLOYEE_ID="00000055">
<EMPLOYEE_ID>00000055</EMPLOYEE_ID>
<FIRSTNAME>Lydia</FIRSTNAME>
<SURNAME>Jones</SURNAME>
<DOB>1965-03-09</DOB>
<SALARY>90000.0</SALARY>
</EMPLOYEE_DETAILS>
</EMPLOYEE_DATA>
</asx:values>
</asx:abap>
But it is repeating the Employee_ID, I want it to start from Firstname, the XSLT I have is:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="item">
<EMPLOYEE_DETAILS>
<xsl:attribute name="EMPLOYEE_ID">
<xsl:value-of select="EMPLOYEE_ID"/>
</xsl:attribute>
<xsl:apply-templates select="node()"/>
</EMPLOYEE_DETAILS>
</xsl:template>
</xsl:transform>
How do I get it to start from the next node?
ThanksHi
I am also trying the similar kind of requirement.
I am trying to convert XML file in to ABAP using transformations.
Problem
When I am trying to execute the Transformation (Selection is Transformation name, Source File Path) using STRANS it is giving the bellow message.
XSLT Tester
Runtime Errors
Reason : No valid XSLT program supplied
Could you please guide me how to test the Transformation using STRANS
Thanks
Nikhil.B -
Error applying XSL stylesheet to XML
Hi,
after installed SPS 21 into portal we are facing an issue:
A contentadministrator wants to publish a new newsfact in portal, but get the following error message:
Error applying XSL stylesheet to XML:
com.sapportals.wcm.WcmException: com.sap.engine.lib.xml.util.NestedException: Variable '$system_config_activateClipboard' has not been bound to a value
at com.sapportals.wcm.service.pipeline.Pipeline.handle(Pipeline.java:284)
Hope that somebody can give me some help.
thanks a lot in advance.
Regards,
EdwinHi Lorcan,
You help solved our issue, thanks a lot.
After generate the existing xml project with the Forms builder in the Content Management,
the contentadministratoris able to produce a new newsfact without errors
Regards, edwin
Posts: 123
Registered: 11/29/04
Forum Points: 346
Solved problem (10)
Very helpful answer (6)
Helpful answer (2)
Re: Error applying XSL stylesheet to XML
Posted: Apr 19, 2010 11:13 AM in response to: Edwin Theuns Reply
Hi Edwin,
You need to recompile the xml forms project and that should resolve the issue. Unfortunately there is no alternative solution in such a scenario.
Regards,
Lorcan.
Maybe you are looking for
-
Logical database PCH,Extended Object ID
When using logical database PCH.I found Object structure has a component REALO means extended object id. Can somebody give a example to show the actual meaning of extended object id? thanks. Edited by: Lanmbor Yang on May 30, 2008 8:40 AM
-
Reg BAPI_PO_CREATE1
Hi guys, Im using the above said BAPI for PO Creation. Im getting errors in the return table sayinh "Net price should be greater than Zero". I tried testing the BAPI thro se37, where it doesnot give me any errors in the return table and automatically
-
HELP - 11.1.2 Planning app not rolling up on blank values (#missing)
Stumped looking for avenues. On 11.1.2 with critical patches applied on Windows 2008 SP1 environment We have a simple planning app with not much data. We have a dimension called 'Funding Source' example shown below: Funding Source (Level 2) DME (Leve
-
Which partition format to choose to make second internal drive read/write for Windows 7
Hi, I have a new Mac Mini Server 2011 and I would like to split partition my second internal hard drive to use in Bootcamp Windows 7. I would like to split this drive so that I can have one partition in NTFS and other half in standard MAC OS format.
-
I just downloaded Java for OS X 2014-001 and my printer is not recognized. I use an Epson Workforce 630. Has anyone had similar problems?