XML/XSLT Newbie
Hi All
I'm want to dip my toe into the world of XML/XSLT development
to help with
job applications. Seems there's a lot of companies asking for
this.
I've been developing ASP applications for a number of years,
but i've never
looked at XML, etc...
Can anyone provide a strating point, examples, etc? I'm also
looking to
learn .NET too (think i have a mountain to climb).
I've been using Access database for my applications but also
need to expand
by using MS SQL on my local machine.
Any ideas wher to start?
Hope someone can point me in the right direction - Thanks in
Adance
Andy
> Can anyone provide a strating point, examples, etc? I'm
also looking to
> learn .NET too (think i have a mountain to climb).
And at the top of that mountain is a pile of .net XML
applications. I can't
say that's the motherland of software development, but, yea,
it probably
pays good. ;o)
> Any ideas wher to start?
Well, if you start using asp.net 2.0, a lot of the built-in
controls
leverage XML and XSLT, so you'll begin to get your hand dirty
just going
through the basic ASP.net 2.0 tutorials.
-Darrel
Similar Messages
-
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. -
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! -
OT:XML/XSLT transformations on iAS6.0 anyone?
Hi,
I know this is Off Topic from JATO, but...
I am trying to come up with a way to process the typical
transformation of xml & xslt to html.
For whatever reason I can't seem to get this to work.
I've tried it by writing my own servlet, but it hangs.
I've tried to install cocoon, but nothing ever works, and all the
installation instructions seem to trail off at the most important time
(like what if the build doesn't create a war file).
Can someone point to a definitive resource that I can follow for
something like this which will work on iAS6.0?
Thanks,
John Hoskins.Yeah, off topic, so I doubt you will get any expert help here. Might try the S1AS 6.x forum.
sorry -
Java Translets XML/XSLT Transformation
Translets "are precompiled XSL documents that are optimized and converted into simple Java classes. When you compile your application Java files, you compile your XSL files into Java class files. During runtime, you can load translets like any regular Java class and perform XSL transformations over and over again.
The syntax checking and parsing of XSL documents are done when the XSL files are compiled. The transformation therefore takes only as long as the compiled code takes to execute, which improves performance multiple folds.
The downside to using XSL is that "it can take a considerable amount of time and reduce performance. The time needed to parse XML and XSL documents is directly proportional to the size of the documents. Each transformation requires the XML and XSL documents to be loaded, syntax checked, and parsed." I recommends using translets for the following reasons.
I had written an application (<a href="http://www.simplygites.com" title="www.simplygites.com">SimplyGites</a>) using standard XSL / XML transformation and experienced some very slow server-side transformation on the very complex screens with large amounts of xml. Timings showed these problem screens took 2-3 seconds to transform, which was totally unacceptable non-functional requirements.
I considered rewriting these screens as JSP or PHP, then I discovered Translets. And wow what a discovery the timings for these pages now compiled as Translets(java classes) are amazing in comparison to the original timings ? I now have them transforming in 500ms (all now under 1 second).
I would recommend anyone using XSL/XML transformation to use Translets, these have now been running tried and tested on the <a href="http://www.simplygites.com" title="www.simplygites.com">SimplyGites</a> for the past 6months.
Technolgies used:
Weblogic 8.1 SP5
Java 1.4.2
Required Jars
xsltc.jar
runtime.jar
BCEL.jar
JLex.jar
java_cup.jar
regexp.jar
xml-dtm.jar
For more information see http://xml.apache.org/xalan-j/xsltc_usage.html
I hope this helps anyone that has XML/XSLT performance issues.
Mark
MB Computer Ltd
www.simplygites.comThanks for your help.
The problem was that my firewall was blocking my server. -
Turning XML/XSLT files into a working Web Template
I've scoured these and other forums for this small piece of information, so I apologize if it's been answered already, but I can't find it.
I understand that the web templates in Lightroom are done in XML/XSLT, with the XML file named galleryMaker.xml and the XSLT file named transformer.xslt. However, I cannot figure out how to get these files to show up as a template in Lightroom.
I am on a Windows XP machine, and all the templates show up in Application Data/Lightroom/Web Templates, but they are all of the type *.lrtemplate. Is there a way to convert the XML/XSLT set of files into an lrtemplate file? Or is there something else I'm supposed to do?Splatt42 wrote:
I have an executable binary program (that runs just fine on it's own) that I needed to turn into a service (call it "foo"). I did so using the .xml file below, and it does indeed start up at boot, runs in the background,When you run your program (/usr/bin/foo), does it daemonize itself (kind of like running /usr/sbin/sshd), or would you have to do it yourself if run from the shell ('/usr/bin/foo &')?
and does everything it should. I've noticed a couple of problems, though. If I execute an init 0, the system hangs and never gets to the OK prompt. If I disable my service, an init 0 completes without any problems. An init 5 works OK, as does a shutdown from the desktop. I'm not sure what could be causing this. I thought maybe because the service was restarted over and over again...?
I gave my service a timeout value of "0", as I found that when I gave it any other value the service stopped running when the timeout expired. A seeming side effect is that my service is never listed as running, as it's start method (itself) hasn't yet completed.The manifest doesn't really want your binary as the start method. It wants to run something that starts the service, and will exit with status 0 if the startup was successful, and non-zero if the startup was unsuccessful. So you might want to write a small wrapper script (like an init.d startup script).
Take a look at the sshd.xml manifest. It doesn't start sshd, it runs '/lib/svc/method/sshd start', which is responsible for starting sshd.
Darren -
On XML, XSLT, FO usage
Hi,
Any links... help...documents... tutorials... samples on usage of XML, XSLT, FO engine, for pdf generation.
Ravishankar SwamyHi,
This Technical Note is very interesting to start point
http://www.oracle.com/technology/pub/notes/technote_vohra_fop.html
Follow good references from AMIS
http://technology.amis.nl/blog/?p=1102
http://technology.amis.nl/blog/?p=1182
Best regards -
Job Opening: DITA - XML - XSLT at Mentor Graphics
Mentor Graphics has the following open postion:
Title: Technical Publications Infrastructure Engineer (XML - XSLT - DITA)
Position based: Wilsonville, Oregon
Please follow the link to the job description: http://ch.tbe.taleo.net/CH08/ats/careers/requisition.jsp?org=MENTOR&cws=1&rid=1023I would have applied myself, but unfortunatley someone made it so you can see other people's post history.
-
How to do the following XML/XSLT operation in a Java Oracle function?
I'd like to write a Java method with the following signature...
public static oracle.xdb.XMLType bwdtransform(java.lang.String suname, oracle.sql.CLOB documentText)
The documentText is simply a CLOB that contains the XML. It needs to have two XSLT stylesheets applied to it, then made into an XMLType and returned.
Another requirement is that the stylesheets have to have the Java XPath extensibility, which is available using the namespace "xmlns:java.lang.String="http://www.oracle.com/XSL/Transform/java/java.lang.String".
I've tried a couple of different ways using oracle.xdb.XMLType.transform() and the classes in the oracle package oracle.xml.parser.v2.*, which is what the listing I pasted in below is based on, but I haven't been able to get anything to work. I THINK the XMLType.transform failed because I was using the Java XPath extensions.
I'd appreciate it if there's a standard Oracle recommended way to do this operation, preferably as optimized as possible.
Here btw is the current code I'm using which isn't working. Any variables that you see that aren't initialized in the function are static to the class and initialized in a static {} block including the stylesheets which are instances of XSLStylesheet.
public static XMLType bwdtransform(java.lang.String suname, oracle.sql.CLOB documentText) throws Exception {
parser.parse(new ByteArrayInputStream(clobToString(documentText).getBytes()));
XMLDocument documentTextXMLDocument = parser.getDocument();
XMLDocumentFragment docFrag = processor.processXSL(twiddlerXSLStylesheet, processor.processXSL(adopterXSLStylesheet, documentTextXMLDocument));
Document intermediateDoc = docFrag.getOwnerDocument();
XMLType x = new XMLType(conn, intermediateDoc);
return x;
I haven't been able to find any way to make this work and any any help in that direction would be oh so greatly appreciated.
For completeness, here's the version of Oracle I'm running, according to sqlplus...
SQL*Plus: Release 11.1.0.7.0 - Production on Thu Apr 30 20:24:53 2009
Thanks!
RalphThe XMLDB way of doing this like this would be something like the following examples:
SELECT XMLtransform(x.xmlcol,
DBURIType('/XDB/STYLESHEET_TAB/ROW[ID=1]
/STYLESHEET/text()').getXML()).getStringVal()
AS result
FROM po_tab x; or
SELECT XMLtransform(x.xmlcol,
(SELECT stylesheet FROM stylesheet_tab WHERE id=1)).getStringVal()
AS result
FROM po_tab x; or use DBMS_XSLPROCESSOR... -
Hi,
I'm actually doing some tests with the possibility to invoke a ABAP-Mapping (ABAP-Class).
So my scenario is quite simple:
I have a import xml where I want to substitute exactly one value (database select).
Now my problem is that the xml comes in with a namespace at the toplevel element (I wrote the complete source string to the trace in my execute function) called "ns0".
So I stored the output of the trace to a local file for testing and developing a XSLT-Mapping.
In debugging mode I see that the command:
<xsl:for-each select="ns0:BAPI_SALESORDER_CREATEFROMDAT2/ORDER_PARTNERS">
doesn't work as (I) expected (want to loop at the partners) on this content:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:BAPI_SALESORDER_CREATEFROMDAT2 xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
<ORDER_HEADER_IN>
<DOC_TYPE>TA</DOC_TYPE>
<SALES_ORG>1000</SALES_ORG>
<DISTR_CHAN>10</DISTR_CHAN>
<DIVISION>00</DIVISION>
<PURCH_NO_C>654</PURCH_NO_C>
</ORDER_HEADER_IN><ORDER_ITEMS_IN>
<item>
<PO_ITM_NO>10</PO_ITM_NO>
<MATERIAL>100-100</MATERIAL>
<TARGET_QTY>100</TARGET_QTY>
<T_UNIT_ISO>PCE</T_UNIT_ISO>
</item>
<item><PO_ITM_NO>20</PO_ITM_NO>
<MATERIAL>P-100</MATERIAL>
<TARGET_QTY>100</TARGET_QTY>
<T_UNIT_ISO>PCE</T_UNIT_ISO>
</item>
</ORDER_ITEMS_IN>
<ORDER_PARTNERS>
<item>
<PARTN_ROLE>AG</PARTN_ROLE>
<PARTN_NUMB>0000001000</PARTN_NUMB>
</item>
<item>
<PARTN_ROLE>WE</PARTN_ROLE>
<PARTN_NUMB>0000001000</PARTN_NUMB>
</item>
</ORDER_PARTNERS>
</ns0:BAPI_SALESORDER_CREATEFROMDAT2>
Anyone an idea?
Thnx
OlliHi Olli,
Did you declare the namespace in the XSLT itself?
Did your write something like?
<xsl:stylesheet
exclude-result-prefixes="xsl ns0"
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
Actually, the prefix is something you can freely choose. It is not necessary to use the same prefix as in the source document. You could just as well use the prefix "x" in your XSLT and write:
<xsl:stylesheet ...
xmlns:x="urn:sap-com:document:sap:rfc:functions">
<xsl:for-each select="x:BAPI_SALESORDER_CREATEFROMDAT2/ORDER_PARTNERS">
Kind regards, Guy Crets -
XML-XSLT problem. Please help
I want to apply an XSLT to my XML to retrieve an element "firstName"
My XSLT is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="customer">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="customerBank">
<b>
<xsl:value-of select="preceding-sibling::customerAddress/street"/>
</b>
</xsl:template>
</xsl:stylesheet>
Expected Output should be:
Jonathan
Chadrick
Antonia
Diane
Jennifer
Andrea
Michael
Mario
My Output is :
JonathanGold32
Jonathan
First National TrustEarthfarm Investment BankEF00123456789123456789012VISA ChadrickPowell45
Chadrick
First National TrustEF00123456789123456789012VISASnowboarding AntoniaSuares28
Antonia
Investment Corporate HoldingsEF00123456789123456789012VISAKayaking DianeChristoff31
Diane
Investment Corporate HoldingsEF00123456789123456789012VISABeach JenniferWestlein41
Jennifer
Investment Corporate HoldingsEF00123456789123456789012VISAKayaking AndreaDesroaches33
Andrea
Investment Corporate HoldingsEF00123456789123456789012VISATrekking MichaelSeva21
Michael
Investment Corporate HoldingsEF00123456789123456789012VISACity breaks MarioGinelli34
Mario
Investment Corporate HoldingsEF00123456789123456789012VISAKayaking
Why are the information from other node coming. Please clarify.
My XML is
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xml" href="cuetomer.xml?>
<customerList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="customerList.xsd">
<customer customerID="jgol001">
<customerName>
<firstName>Jonathan</firstName>
<lastName>Gold</lastName>
<age>32</age>
</customerName>
<customerAddress>
<street>4801 Long Street</street>
<city>Earthfarm</city>
<country>USA</country>
<phoneNumber>123-456-7890</phoneNumber>
<emailAddress>[email protected]</emailAddress>
</customerAddress>
<customerBank>
<bankName>First National Trust</bankName>
<bankName>Earthfarm Investment Bank</bankName>
<IBAN>EF00123456789</IBAN>
<creditCardNum>123456789012</creditCardNum>
<creditCardType>VISA</creditCardType>
</customerBank>
</customer>
<customer customerID="cpow001">
<customerName>
<firstName>Chadrick</firstName>
<lastName>Powell</lastName>
<age>45</age>
</customerName>
<customerAddress>
<street>4802 Long Street</street>
<city>Earthfarm</city>
<country>USA</country>
<phoneNumber>123-456-7890</phoneNumber>
<emailAddress>[email protected]</emailAddress>
</customerAddress>
<customerBank>
<bankName>First National Trust</bankName>
<IBAN>EF00123456789</IBAN>
<creditCardNum>123456789012</creditCardNum>
<creditCardType>VISA</creditCardType>
</customerBank>
<vacationPref>Snowboarding</vacationPref>
</customer>
<customer customerID="asua001">
<customerName>
<firstName>Antonia</firstName>
<lastName>Suares</lastName>
<age>28</age>
</customerName>
<customerAddress>
<street>4803 Long Street</street>
<city>Earthfarm</city>
<country>France</country>
<phoneNumber>123-456-7890</phoneNumber>
<emailAddress>[email protected]</emailAddress>
</customerAddress>
<customerBank>
<bankName>Investment Corporate Holdings</bankName>
<IBAN>EF00123456789</IBAN>
<creditCardNum>123456789012</creditCardNum>
<creditCardType>VISA</creditCardType>
</customerBank>
<vacationPref>Kayaking</vacationPref>
</customer>
<customer customerID="asua006">
<customerName>
<firstName>Diane</firstName>
<lastName>Christoff</lastName>
<age>31</age>
</customerName>
<customerAddress>
<street>4803 Long Street</street>
<city>Earthfarm</city>
<country>Germany</country>
<phoneNumber>123-456-7890</phoneNumber>
<emailAddress>[email protected]</emailAddress>
</customerAddress>
<customerBank>
<bankName>Investment Corporate Holdings</bankName>
<IBAN>EF00123456789</IBAN>
<creditCardNum>123456789012</creditCardNum>
<creditCardType>VISA</creditCardType>
</customerBank>
<vacationPref>Beach</vacationPref>
</customer>
<customer customerID="asua005">
<customerName>
<firstName>Jennifer</firstName>
<lastName>Westlein</lastName>
<age>41</age>
</customerName>
<customerAddress>
<street>4803 Long Street</street>
<city>Earthfarm</city>
<country>UK</country>
<phoneNumber>123-456-7890</phoneNumber>
<emailAddress>[email protected]</emailAddress>
</customerAddress>
<customerBank>
<bankName>Investment Corporate Holdings</bankName>
<IBAN>EF00123456789</IBAN>
<creditCardNum>123456789012</creditCardNum>
<creditCardType>VISA</creditCardType>
</customerBank>
<vacationPref>Kayaking</vacationPref>
</customer>
<customer customerID="asua004">
<customerName>
<firstName>Andrea</firstName>
<lastName>Desroaches</lastName>
<age>33</age>
</customerName>
<customerAddress>
<street>4803 Long Street</street>
<city>Earthfarm</city>
<country>USA</country>
<phoneNumber>123-456-7890</phoneNumber>
<emailAddress>[email protected]</emailAddress>
</customerAddress>
<customerBank>
<bankName>Investment Corporate Holdings</bankName>
<IBAN>EF00123456789</IBAN>
<creditCardNum>123456789012</creditCardNum>
<creditCardType>VISA</creditCardType>
</customerBank>
<vacationPref>Trekking</vacationPref>
</customer>
<customer customerID="asua003">
<customerName>
<firstName>Michael</firstName>
<lastName>Seva</lastName>
<age>21</age>
</customerName>
<customerAddress>
<street>4803 Long Street</street>
<city>Earthfarm</city>
<country>UK</country>
<phoneNumber>123-456-7890</phoneNumber>
<emailAddress>[email protected]</emailAddress>
</customerAddress>
<customerBank>
<bankName>Investment Corporate Holdings</bankName>
<IBAN>EF00123456789</IBAN>
<creditCardNum>123456789012</creditCardNum>
<creditCardType>VISA</creditCardType>
</customerBank>
<vacationPref>City breaks</vacationPref>
</customer>
<customer customerID="asua002">
<customerName>
<firstName>Mario</firstName>
<lastName>Ginelli</lastName>
<age>34</age>
</customerName>
<customerAddress>
<street>4803 Long Street</street>
<city>Earthfarm</city>
<country>Canada</country>
<phoneNumber>123-456-7890</phoneNumber>
<emailAddress>[email protected]</emailAddress>
</customerAddress>
<customerBank>
<bankName>Investment Corporate Holdings</bankName>
<IBAN>EF00123456789</IBAN>
<creditCardNum>123456789012</creditCardNum>
<creditCardType>VISA</creditCardType>
</customerBank>
<vacationPref>Kayaking</vacationPref>
</customer>
</customerList>
Thanks in advance
AmitThanks for the reply.
I was trying to understand the XPath expression axes and was trying to achieve the same by using preceding-sibling.
After some reading I was able to get the desired result by applying the following XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="customerList">
<html>
<b>
<br>
<xsl:apply-templates select="customer/customerAddress"/>
</br>
</b>
</html>
</xsl:template>
<xsl:template match="customerAddress">
<br>
<xsl:value-of select="preceding-sibling::customerName/firstName"/>
</br>
</xsl:template>
</xsl:stylesheet>
Thanks a lot. May be it will be helpful to others. -
Transforming XML/XSLT : CDATA problem
Hi!
I have a problem transforming xml with XSLT using the API javax.xml.
The result is correct until I have a CDATA section in my xml document.
The transforming process encodes all the & < > (special characters) it finds in.
This occurs problem for the follow of my treatement because the content of my CDATA is already encoded.
For example, this xml code :
<?xml version='1.0' encoding="ISO-8859-1" ?>
<article>
<article-contenu><![CDATA[Accent : é Signe : <]]></article-contenu>
</article>
produces in my output :
Accent : &eacute; Signe : &lt;
This is my java code :
TransformerFactory tFactory = TransformerFactory.newInstance();
Source xmlSource = new StreamSource(readerXml);
Source xslSource = new StreamSource( fileXsl );
// Generate the transformer.
Transformer transformer = tFactory.newTransformer(xslSource);
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource, new javax.xml.transform.stream.StreamResult(sw));
How can I tell the transformer not to do that?
Thanks for your answers!I am having a similar problem. I have enclosed my text data in my xml file like this:
<![CDATA[<b>Hello World!</b>]]>
My select statement in my XSLT sheet is as follows:
<xsl:value-of select="." disable-output-escaping="yes"/>
I have tried setting xsl:output to text, to html, and to xml. The <, >, and & get converted to xhtml entities.
Where should I begin to troubleshoot? If the Xalan xslt jars? My stylesheet. My xml doc? Java code?
Any feedback welcome. -
I'm currently reading info on using XSLT with XML documents ("Java Server Programming" by WROX), but I'm having quite a few problems getting anything to work. Can someone point me to a page/document that simply explains what .jar files to install, where to get them and where to place them to enable parsing XML files and using XSLT? I'm running jdk1.3.1_02.
Thank You
Tom Berry- download: http://java.sun.com/xml/downloads/javaxmlpack.html
- install JAXP
- follow the XSLT tutorial: http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXPXSLT.html
- have fun! -
I am very new to java and am trying to do a simple transformation from XML to HTML using.
I have been working in JavaScript and do this all the time but i am really strugling to make it work in JAVA.
i have a simple function
public void transformXML()
try
StreamSource myXSLSource=new StreamSource("style.xsl");
TransformerFactory myFactory =TransformerFactory.newInstance();
Transformer myTransformer = myFactory.newTransformer(myXSLSource);
StreamResult out = new StreamResult("output.html");
myTransformer.transform(new StreamSource(new StringReader("input.xml")), out);
}catch(Exception e){
e.printStackTrace();
and i am trying to transform the following XML
<transXML><test>blah blah</test></transXML>
with this XSL
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:msxsl='urn:schemas-microsoft-com:xslt' version='1.0'><xsl:template match="/"><HTML><HEAD></HEAD><BODY>hahahhahaha</BODY></HTML></xsl:template></xsl:stylesheet>
Now i know i am actually translation nothing here but i just want to prove the concept.
I keep getting the error
javax.xml.transform.transformexception: document root element missing
am i on the right track or completely dreaming, if anyone could help it would be apprechiated.
any tutorials or code snipits would be very helpful as well
thanks
Joenew StreamSource(new StringReader("input.xml"))You are passing the string "input.xml" to be parsed. This obviously isn't valid XML. I expect that you meant "input.xml" to be the name of the file containing your XML, in which case you could just usenew StreamSource("input.xml")(as you did for the XSL source).
PC² -
XML + XSLT - Retaining LF's in output
Hi
I am using FOP to process an XML file to a PDF using a XSLT. The
description column can have LF characters in it, which currently are
getting filtered out. I have converted teh LF's to the escape codes,
but this has had no effect (I do something similar with the greater
than symbol and that works). How do I go about retaining them. This
has been driving me around the bend for ages. Some guidence in this
would be most appreciated.
Below is some sample code illustrating the issue. The second row is
supposed to span multiple lines in the text cell.
------------- XML --------------------------------
<SERVERS>
<SERVER>
<NAME>SERV1.DOMAIN.COM</NAME>
<DESCRIPTION>This description does not have any LF's in the
text</DESCRIPTION>
</SERVER>
<SERVER>
<NAME>SERV2.DOMAIN.COM</NAME>
<DESCRIPTION>This is intended to be a line with a LF between here
and here and another LF between here
and here and another
LF between here
and here</DESCRIPTION>
</SERVER>
</SERVERS>
------------- XSLT -------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:java="http://xml.apache.org/xslt/java"
exclude-result-prefixes="java">
<!-- C:\Files\xml>"C:\Program Files\Apache Software
Foundation\fop-0.20.5\fop.bat" -xml c:\files\xml\servercr.xml -xsl
C:\files\xml\servercr.xsl -pdf c:\temp\xml\servercr.pdf -->
<xsl:template match="SERVERS">
<xsl:variable name="CR" select="'
'"/>
<xsl:variable name="LF" select="'
'"/>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fox="http://xml.apache.org/fop/extensions">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4-L" page-width="297mm"
page-height="210mm" margin-top="10mm" margin-bottom="10mm"
margin-left="10mm" margin-right="10mm">
<fo:region-body margin="10mm"/>
<fo:region-before extent="20mm"/>
<fo:region-after extent="10mm"/>
<fo:region-start extent="10mm"/>
<fo:region-end extent="10mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4-L">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:table table-layout="fixed" border-color="rgb(0,0,0)"
border-style="solid" border-width="1pt">
<fo:table-column column-width="40mm"/>
<fo:table-column column-width="200mm"/>
<fo:table-header background-color="rgb(214,214,214)"
font-size="8pt" font-weight="bold" text-align="center">
<fo:table-row text-align="center" font-size="8pt">
<fo:table-cell border-color="rgb(0,0,0)"
border-style="solid"
border-width="1pt"><fo:block>Server</fo:block></fo:table-cell>
<fo:table-cell border-color="rgb(0,0,0)"
border-style="solid"
border-width="1pt"><fo:block>Description</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:for-each select="SERVER">
<fo:table-row text-align="center" font-size="8pt">
<fo:table-cell border-color="rgb(0,0,0)"
border-style="solid" border-width="1pt">
<fo:block vertical-align="middle">
<xsl:value-of select="NAME"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border-color="rgb(0,0,0)"
border-style="solid" border-width="1pt">
<fo:block vertical-align="middle">
<xsl:value-of select="DESCRIPTION"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
I know this isn't an oracle issue, but hopefully someone can point me in the right direction.
Thanks for your help.
Nick.Hi
Thanks for your response it was very useful.
The attribute linefeed-treatment on its own didn't solve the problem, and another link I found suggested that may be a bug. However making use of the attribute white-space-collapse did seem to do what I wanted!
So it loks like the solution is to use one bug to fix another :) I'm sure that can't be good and is asking for problems later on. But for now it will do.
Many thanks for your guidance.
Nick.
Maybe you are looking for
-
SAP BUSINESS ONE 8.8 + 64-Bit-Edition von Office 2010
Hallo Leute, gibts da schon Neuigkeiten, ob B1 und Office 2010 64-Bit zusammen spielen können? Funktioniert der Export nach Excel überhaupt noch? Vielen Dank Grüße, Lukasz.
-
How can I burn a dvd without using iDVD?
It doesn't come with new macs anymore. I want to burn an iMovie i made, but my new mac didn't come with iDVD. I asked someone at an apple store and they told me that they weren't making it anymore. I need to burn something and make a menu, but I don'
-
Problem with creation of a file in a process chain
Hello dears, I included a abap program in a process chain. This abap program allows to create a file in a directory. I'm using the function module GUI_DOWNLOAD for this. 1/ When I execute the program in SE38, it creates the file in the directory. 2/
-
How to create a retro 3d text effect in indesign Cs6?
Hello, i need to know how to make this retrolift 3d text effext in indesign.
-
Dear All, I can't post in fiscal year 2010. So, I posted data in fiscal year 2008. But when I run reports, system have error message :"Message no. MQ593: Current fiscal year 2008 in company code 1000 does not match present year" How do I do? if I wan