Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
|
Using XML Parser for Java, 22 of 22
I don't know what is wrong here. This is my news_xsl.xsl file:
<?xml version ="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <HTML> <HEAD> <TITLE> Sample Form </TITLE> </HEAD> <BODY> <FORM> <input type="text" name="country" size="15"> </FORM> </BODY> </HTML> </xsl:template> </xsl:stylesheet>
ERROR:End tag 'FORM' does not match the start tag 'input'. Line 14, Position 12 </FORM>- ----------^news.xml <?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="news_xsl.xsl"?> <GREETING/>
Unlike in HTML, in XML you must know that every opening/starting tag should have an ending tag. So even the input that you are giving should have a matching ending tag, so you should modify your script like this:
<FORM> <input type="text" name="country" size="15"> </input> </FORM>
OR
<FORM> <input type="text" name="country" size="15"/> </FORM>
And also always remember, in XML the tags are case sensitive, unlike in HTML. So be careful.
Is the output method "html" supported inthe recent version of the XML/XSL parser?I was trying to use the <BR> tag with the<xsl utput method="xml"/> declaration butI got an XSLException error message indicating a not well-formed XML document. Then I tried the following output methoddeclaration: <xsl utput method="html"/>but I got the same result?!
Here's a simple XSL stylesheet I was using:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html"/> <xsl:template match="/"> <HTML> <HEAD></HEAD> <BODY> <P> Blah blah<BR> More blah blah<BR> </P> </BODY> </HTML> </xsl:template>
My question is: "How do I use a not well-formed tags (like <IMG>, <BR>, etc.)in a XSL stylesheet?"
We fully support all options of <xsl utput> The problem here is that your XSL Stylesheet must be a well-formed XML document, so everywhere you are using the <BR> element, you need to use <BR/> instead.<xsl utput method="html"/> requests that when the XSLT Engine *writes out* the result of your transformation, is a proper HTML document. What the XSLT engine reads *in* must be well-formed XML.
Sorry for jumping in on this thread, but I have a question regarding your reply. I have an XSL stylesheet that preforms XML to HTML conversion. Everything works correctly with the exception of those HTML tags that are not well formed. Using your example if I have something like:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> ...... <input type="text" name="{NAME}" size="{DISPLAY_LENGTH}" maxlength="{LENGTH}"> </input> ...... </xsl:stylesheet>
It would render HTML in the format of
<HTML>......<input type="text" name="in1" size="10" maxlength="20"/> ...... </HTML>
While IE can handle this Netscape can not. Is there anyway to generate completely cross browser complient HTML with XSL?
If you are seeing:
<input ... />
instead of:
<input>
Then you are likely using the incorrect way of calling XSLProcessor.processXSL() since it appear that it's not doing the HTML output for you. Use:
void processXSL(style,sourceDoc,PrintWriter)
instead of:
DocumentFragment processXSL(style,sourceDoc)
and it will work correctly.
I'm using <xsl utput method="html" encoding="iso-8859-1" indent = "no" />. Is it possible to prevent XSL-T from outputting <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> in the head because Netscape 4.0 has difficulties with this statement. It renders the page twice.
The XSLT 1.0 Recommendation says in Section 16.2 ("HTML Output Method")...If there is a HEAD element, then the html output method should add a META element immediately after the start-tag of the HEAD element specifying the character encoding actually used.
For example:
<HEAD><META http-equiv="Content-Type" content="text/html; charset=EUC-JP">.
So any XSLT 1.0-compliant engine needs to add this.
Netscape 4.0 has following bug:
When Mozilla hits the meta-encoding tag it stops rendering the page and does a refresh. So you experience this anoying flickering. So I probably have to do a replacement in the servlets Outputstream, butI don't like doing so. Are there any alternatives.
Only alternatives I can think of are:
Neither is pretty, but either one might provide a workaround.
Where can I find more info on the XSL error messages. I get the error XSL-1900 , exception occurred. What does this mean ? How can I find out what caused the exception ?
If you are using Java, you could write Exception routines to trap errors.Using tools such as JDeveloper also helps.
The error messages of our components are usually more legible. XSL-1900 indicates possible internal error or incorrect usage. Please post a code sample that produces this error including your sample XML and DTD file if applicable.
I am trying to generate an HTML form for inputting data using column names from the user_tab_columns table and the following XSL code:
<xsl:template match="ROW"> <xsl:value-of select="COLUMN_NAME"/> <: lt;INPUT NAME="<xsl:value-of select="COLUMN_NAME"/>> </xsl:template>
although 'gt;' is generated as '>' 'lt;' is generated as '#60;'. How do I generate the "<" character?
Using the following:
<xsl:text disable-output-escaping="yes">entity-reference</xsl:text>
does what I need.
I can't seem to display HTML from XML.In my XML file I store the HTML snippet in an XML tag:
<PRE> <body.htmlcontent> <<table width="540" border="0" cellpadding="0" cellspacing="0"><tr><td><font face="Helvetica, Arial" size="2"><!-- STILL IMAGE GOES HERE --><img src="graphics/imagegoeshere.jpg" width="200" height="175" align="right" vspace="0" hspace="7"><!-- END STILL IMAGE TAG --><!-- CITY OR TOWN NAME GOES FIRST FOLLOWED BY TWO LETTER STATE ABBREVIATION --><b>City, state abbreviation</b> - <!-- CITY OR TOWN NAME ENDS HERE --><!-- STORY TEXT STARTS HERE -->Story text goes here.. <!-- STORY TEXT ENDS HERE --></font></td></tr></table> </body.htmlcontent> </PRE>
I use the following in my XSL:
<xsl:value-of select="body.HTMLcontent" disable-output-escaping="yes"/>
However, the HTML output
<PRE><</PRE>
is still outputted and all of the HTML tags are displayed in the browser. How do I display the HTML properly?
That doesn't look right. All of the < are #60; in the code with an ampersand in front of them. They are still that way when they are displayed in the browser.
Even more confusing is that it works withoraxsl, but not with XSLSample.java.
This makes sense. Here's why:
The former supports <xsl:output> and all options related to writing out output that might not be valid XML (including the disable output escaping). The latter is pure XML-to-XML tree returned, so no <xsl:output> or disabled escaping can be used since nothing's being output, just a DOM tree fragment of the result is being returned.
Is there any site which has good examplesor small tutorials on XSL-T?
This site is an evolving tutorialon lots of different XML/XSLT/XPath-related subjects:
http://zvon.vscht.cz/ZvonHTML/Zvon/zvonTutorials_en.html
I am in the process of trying to convert an xml document from one format to another by means of an xsl (or xslt) stylesheet. Before incorporating it into my java code, I tried testing the transformation from the command line:
> java oracle.xml.parser.v2.oraxsl jwnemp.xml jwnemp.xsl newjwnemp.xml
The problem is that instead of returning the transformed xml file (newjwnemp.xml), the above command just returns a file with the xsl code from jwnemp.xsl in it. I cannot figure out why this is occurring. I have attached the two input files.
<?xml version="1.0"?> <employee_data> <employee_row> <employee_number>7950</employee_number> <employee_name>CLINTON</employee_name> <employee_title>PRESIDENT</employee_title> <manager>1111</manager> <date_of_hire>20-JAN-93</date_of_hire> <salary>125000</salary> <commission>1000</commission> <department_number>10</department_number> </employee_row> </employee_data> <?xml version='1.0'?> <ROWSET xmlns:xsl="HTTP://www.w3.org/1999/XSL/Transform"> <xsl:for-each select="employee_data/employee_row"> <ROW> <EMPNO><xsl:value-of select="employee_number"/></EMPNO> <ENAME><xsl:value-of select="employee_name"/></ENAME> <JOB><xsl:value-of select="employee_title"/></JOB> <MGR><xsl:value-of select="manager"/></MGR> <HIREDATE><xsl:value-of select="date_of_hire"/></HIREDATE> <SAL><xsl:value-of select="salary"/></SAL> <COMM><xsl:value-of select="commission"/></COMM> <DEPTNO><xsl:value-of select="department_number"/></DEPTNO> </ROW> </xsl:for-each> </ROWSET>
This is occurring nearly 100%-likely because you have the wrong XSL namespace uri for your xmlns:xsl="..." namespace declaration.
If you use: xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
everything works.
If you use xmlns:xsl="-- any other string here --"
If will do what you're seeing.
I cannot find anything about using XSL. Can you help? I would like to get an XML and XSL file to show my company what thay can expect from this technology. XML alone is not very impressive for users.
A pretty good starting place for XSL is the following page:
http://metalab.unc.edu/xml/books/bible/updates/14.html
It shows pretty much in english what the jist of xsl is. XSL isn't really anything more than an XML file anyways, so I don't think that it will be anymore impressive to show to a customer. There's also the main website for xsl which is:
http://www.w3.org/style/XSL/
I recall seeing discussions about XSLProcessor producing more than one result from one XML and XSL. How can this can be achieved?
XML Parser 2.0.2.8 supports <ora:output> to handle this.
Can any one suggest good books for learning about XML/XSL?
There are many excellent articles, whitepapers, and books that describe all facets of XML technology. Many of these are available on the world wide web. The following are some of the most useful resources we have found:
How do I determine the version number of the XDK toolkit that I downloaded?
You can find out the full version number by looking at the readme.html file included in the archive and linked off of the Release Notes page.
How do I include binary data in an XML document?
There is no way to directly include binary data within the document; however, there are two ways to work around this:
How do I convert XML files into HTML files?
You need to create an XSL stylesheet to render your XML into HTML. You can start with an HTML document in your desired format and populated with dummy data. Then you can replace this data with the XSLT commands that will populate the HTML with data from the XML document completing your stylesheet.
I would like to know if there are any release plans for the XML Parser or an XDK for HP/UX platform.
HP-UX ports for our C/C++ Parser as well as our C++ Class Generator are available. Look for an announcement on http://technet.oracle.com
|
Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|