XML Transformation help required
Hi,
I want to read the contents of XML file, so i want to use Transformation. I require your help in getting that.
XML File contents
- <SOAP_FAULT>
- <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
- <s:Header>
<a:Action s:mustUnderstand="1">http://www.aaaa/bbbb/ccccc/ServiceUnavailableFault</a:Action>
<a:RelatesTo>urn:uuid:18a90558-58e4-1ee0-b5b6-4406eadff48f</a:RelatesTo>
- <u:Timestamp u:Id="_0">
<u:Created>2011-09-02T22:23:11.917Z</u:Created>
<u:Expires>2011-09-02T22:28:11.917Z</u:Expires>
</u:Timestamp>
</s:Header>
- <s:Body>
- <s:Fault>
- <s:Code>
<s:Value>s:Sender</s:Value>
</s:Code>
- <s:Reason>
<s:Text xml:lang="en-US">No recipients found</s:Text>
</s:Reason>
+ <s:Detail>
- <ServiceUnavailableFault xmlns="http://www.aaabbbccc.com/AONI/2/0/messages/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<RequestId>18a90558-58e4-1ee0-acc4-b45d6629582d</RequestId>
</ServiceUnavailableFault>
</s:Detail>
</s:Fault>
</s:Body>
</s:Envelope>
</SOAP_FAULT>
Here i want to read the tag <Reason> which is currenlyt displaying as "No recipients found".
could you please help me in getting this..?
Thaks,
Raghu
Hi,
if you just need to extract one element (?), you could use iXML : interface if_ixml_document contains method find_from_path_ns , to which you may pass the path to your element (and pass the namespace prefix too), which is :
/SOAP_FAULT/s:Envelope/s:Body/s:Fault/s:Reason
Sandra
Similar Messages
-
XML Transformation HELP!!!
I am having the input XML
<SalesOrder>
<Text type="Test1">First key</Text>
<Text type="Test2">Second key</Text>
<Text type="Test2">Third key</Text>
<Text type="Test2">Forth key</Text>
<Text type="Test3">Fifth key</Text>
</SalesOrder>
and I want this to be transformed to
<SalesOrder>
<Text type="Test1">First key</Text>
<Text type="Test2">Second key/Third key/Forth key</Text>
<Text type="Test3">Fifth key</Text>
</SalesOrder>
I need to transform this using XSL and I've tried all night to come up with an XSL for this. I am not an XSL expert and hence finding it really tough. any help appreciated!!!
Shyamno I just provided a sample for explanation, no hard-coded should be done here.
The rule is.. if the value of the 'type' attribute of 'Text' node is repeating, then the output must have only one 'Text' node with one 'type' attribute, and the element values needs to be concatenated with a '/'.
hope I am understandable here.
Shyam -
PLS HELP: XML Transformation using Saxon8
I am using XSL version2.0 and the xalan parser is not recognizing the tokenize function in the XSLT.
Now I am trying to transform the XML using Saxon8. But it is giving exception...
java.lang.ClassNotFoundException ---> java.lang.AssertionError.
at java.lang.Class.forName(Class.java:142)
at net.sf.saxon.functions.ExtensionFunctionFactory.class$(ExtensionFunctionFactory.java:21)
at net.sf.saxon.functions.ExtensionFunctionFactory.<init>(ExtensionFunctionFactory.java:21)
at net.sf.saxon.Configuration.<init>(Configuration.java:87)
at net.at net.sf.saxon.TransformerFactoryImpl.<init>(TransformerFactoryImpl.java:44)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java:262)
at javax.xml.transform.FactoryFinder.newInstance(Unknown Source)
at javax.xml.transform.FactoryFinder.find(Unknown Source)
at javax.xml.transform.TransformerFactory.newInstance(Unknown Source)
at SAXTest.main(SAXTest.java:
the following is the code...
Please help in solving the problem...
import javax.xml.transform.*;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.*;
import net.sf.saxon.*;
public class SAXTest {
public static void main(String[] args) {
String strResult = new String();
File xmlFile = new File("source.xml");
File xslFile = new File("input.xsl");
System.setProperty"javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl");
StringWriter xmlString = new StringWriter();
StreamSource xmlSource = new StreamSource(xmlFile);
StreamSource xslSource = new StreamSource(xslFile);
StreamResult result = new StreamResult(xmlString);
TransformerFactory trans = TransformerFactory.newInstance();
try
Transformer transformer = trans.newTransforme(xslSource) transformer.transform(xmlSource,result);
System.out.println("result = "+result.toString());
}catch(Exception e){}
Please help me....It depends on your jre version if you have jre 1.4 .
You can get your TransformerFactory instance using javax.xml.transform.TranformerFactory.newInstance() directrly.
If your jre version is higher than *1.4* than try to locate this class in your rt.jar in jre lib directory.
When you found that class replace your code
System.setProperty("javax.xml.transform.TransformerFactory","your desired TransformerFactoryClass") than run the code you wont find that error again.
If you want some details copy and paste your error in google search you will found same problems posted by different programmers on forums however i have seen them before. Hope this help. Sorry if i have misunderstood your problem. -
XSLT mapping Help Required.
XSLT mapping Help Required.
Hi Experts,
I am New to XSLT Mapping. I am practising the below Example:
InputXML File:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
<ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
<Person>
<FirstName>Anshul</FirstName>
<LastName>Chowdhary</LastName>
<Gender>Male</Gender>
<Address>
<Street>2nd Main</Street>
<Houseno>83/b</Houseno>
<City>Mysore</City>
</Address> </Person>
</ns0:MT_XSLT_Source>
XSL StyleSheet File:
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/Gen"
Xmlns:ns1=”http://XYZ.com/Test”>
<xsl:template match="/">
<ns1:MT_XSLT_Target>
<Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title>
<Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/>
</Name>
<Street> <xsl:value-of select="concat(concat(ns0:Mt_XSLT_Source/Person/Address/Houseno,' '),
ns0:Mt_XSLT_Source/Person/Address/Street)"/> </Street>
<City> <xsl:value-of select="ns0:Mt_XSLT_Source/Person/Address/City"/> </City>
</ns1:MT_XSLT_Target>
</xsl:template>
</xsl:stylesheet>
The Desired Output shuold be:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MT_XSLT_Target xmlns:ns1="http://XYZ.com/Test">
<Title>Male</Title>
<Name>Anshul Chowdhary</Name>
<Street>83/b 2nd Main</Street>
<City>Mysore</City>
</ns1:MT_XSLT_Target>
I have refered the xsl in xml and i am getting the below Oupt in a Single line like this:
Anshul Chowdhary Male 2nd Main 83/b Mysore
I am Unable to display in Target XML Fomrat as shown above. Please check and do the needful.
Regards,
GIRIDHARHi,
I have used below for testing.
Input xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Persons111.xsl"?>
<ns0:MT_XSLT_Source xmlns:ns0="http://XYZ.com/gen">
<Person>
<FirstName>Anshul</FirstName>
<LastName>Chowdhary</LastName>
<Gender>Male</Gender>
<Address>
<Street>2nd Main</Street>
<Houseno>83/b</Houseno>
<City>Mysore</City>
</Address> </Person>
</ns0:MT_XSLT_Source>
xsl code:
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://XYZ.com/gen"
xmlns:ns1="http://XYZ.com/Test">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<ns1:MT_XSLT_Target>
<Title> <xsl:value-of select="ns0:MT_XSLT_Source/Person/Gender"/> </Title>
<Name> <xsl:value-of select="concat(concat(ns0:MT_XSLT_Source/Person/FirstName,' '), ns0:MT_XSLT_Source/Person/LastName)"/>
</Name>
<Street> <xsl:value-of select="concat(concat(/ns0:MT_XSLT_Source/Person/Address/Houseno,' '),
/ns0:MT_XSLT_Source/Person/Address/Street)"/> </Street>
<City> <xsl:value-of select="/ns0:MT_XSLT_Source/Person/Address/City"/> </City>
</ns1:MT_XSLT_Target>
</xsl:template>
</xsl:stylesheet>
For testing in PI ,change the extension from .txt to .xsl and zip it and upload into PI as an imported archive .
Regards
Venkat -
Javax.xml.transform.TransformerConfigurationException
Hi,
I am deploying a bpel process and a bpel test to a remote oc4j, then running the tests via an ant build script.
The tests are run fine and the results are created in an xml file, however the bpeltest task then try's to convert the xml to a junit report xml format and throws an exception when it can't find bpeltest-junit.xsl.
The exception is vague and I don't know if its because it can't find the xls file our one of its dependancies.
exception,
[bpeltest] ERROR: 'File "" not found.'
[bpeltest] FATAL ERROR: 'Could not compile stylesheet'
[bpeltest] javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
[bpeltest] at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
[bpeltest] at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:619)
[bpeltest] at com.collaxa.cube.ant.taskdefs.BpelTest.doXForm(BpelTest.java:615)
[bpeltest] at com.collaxa.cube.ant.taskdefs.BpelTest.createJUnitReport(BpelTest.java:685)
[bpeltest] at com.collaxa.cube.ant.taskdefs.BpelTest.createReport(BpelTest.java:877)
[bpeltest] at com.collaxa.cube.ant.taskdefs.BpelTest.execute(BpelTest.java:1033)
[bpeltest] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[bpeltest] at org.apache.tools.ant.Task.perform(Task.java:364)
[bpeltest] at org.apache.tools.ant.Target.execute(Target.java:341)
[bpeltest] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[bpeltest] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[bpeltest] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[bpeltest] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[bpeltest] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[bpeltest] at org.apache.tools.ant.Main.runBuild(Main.java:668)
[bpeltest] at org.apache.tools.ant.Main.startAnt(Main.java:187)
[bpeltest] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
[bpeltest] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
My ant script invokes the test as follows,
<bpeltest
user="oc4jadmin"
password="babylon5"
hostname="wells175732.int.rdel.co.uk"
httpport="80"
domain="default"
process="AmazonFlow"
rev="${rev}"
name="AmazonFlowTests"
timeout="${bpeltest.timeout}"
numWorkers="${bpeltest.numWorkers}"
minCoverage="${bpeltest.minCoverage}"
callHandler="${bpeltest.callHandler}"
context="${bpel.context.properties}"
resultsDir="${basedir}/bpel_test_results"
resultsPropertyFile="${basedir}/bpel_test_results/AmazonFlow.properties"
failonerror="false"
verbose="false"/>
the top of my build script imports the following dependancies,
<property file="${basedir}/conf/ant-oracle.properties"/>
<property name="bpel.home" value="${oracle.home}/bpel"/>
<import file="${bpel.home}/utilities/ant-orabpel.xml"/>
<import file="${basedir}/conf/ant-oracle.xml"/>
<property file="${bpel.home}/utilities/ant-orabpel.properties"/>
<property file="${bpel.home}/utilities/bpel_build_template.properties"/>
ant-oracle.xml conatins all necessary jar files including the orabpel-ant.jar where the bpeltest-junit.xsl resides under com\collaxa\cube\ant
In the bpelTest ant task their is an attribute callHandler="${bpeltest.callHandler}"
this property value is defined in the bpel_build_template.properties file but is empty,
bpeltest.callHandler =
I tried changing this to
bpeltest.callHandler = com.collaxa.cube.ant.taskdefs.BpelTest
and build script threw the following exception,
[bpeltest] java.lang.ClassCastException: com.collaxa.cube.ant.taskdefs.BpelTest
[bpeltest] at com.collaxa.cube.ant.taskdefs.BpelTest.loadHandler(BpelTest.java:425)
[bpeltest] at com.collaxa.cube.ant.taskdefs.BpelTest.runTestsOverRMI(BpelTest.java:544)
[bpeltest] at com.collaxa.cube.ant.taskdefs.BpelTest.runTests(BpelTest.java:603)
[bpeltest] at com.collaxa.cube.ant.taskdefs.BpelTest.execute(BpelTest.java:1024)
[bpeltest] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[bpeltest] at org.apache.tools.ant.Task.perform(Task.java:364)
[bpeltest] at org.apache.tools.ant.Target.execute(Target.java:341)
[bpeltest] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[bpeltest] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[bpeltest] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[bpeltest] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[bpeltest] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[bpeltest] at org.apache.tools.ant.Main.runBuild(Main.java:668)
[bpeltest] at org.apache.tools.ant.Main.startAnt(Main.java:187)
[bpeltest] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
[bpeltest] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
the xsl file looks as follows,
<?xml version="1.0" encoding="UTF-8" ?>
<?oracle-xsl-mapper
<!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
<mapSources>
<source type="XSD">
<schema location="UTResult.xsd"/>
<rootElement name="testRunResults" namespace="http://xmlns.oracle.com/bpel/unittest"/>
</source>
</mapSources>
<mapTargets>
<target type="XSD">
<schema location="JUnit.xsd"/>
<rootElement name="testsuites" namespace=""/>
</target>
</mapTargets>
<!-- GENERATED BY ORACLE XSL MAPPER 10.1.2.0.0(build 050412) AT [SUN APR 17 02:06:34 PDT 2005]. -->
?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://xmlns.oracle.com/bpel/bpeltest"
xmlns:utd="http://xmlns.oracle.com/bpel/instancedriver"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:ora="http://schemas.oracle.com/xpath/extension"
xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
xmlns:java="http://xml.apache.org/xslt/java"
exclude-result-prefixes="xsl ns0 utd xsd ldap xp20 bpws ora orcl">
<xsl:param name="minCodeCoverage">0</xsl:param>
<xsl:param name="minPartnerCodeCoverage">0</xsl:param>
<xsl:param name="packageFormat"/>
<xsl:template match="/">
<testsuites>
<xsl:for-each select="/ns0:testRunResults/ns0:testSuite">
<testsuite>
<xsl:attribute name="name">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getQualifiedSuite($packageFormat, ../@domain, ../@processName, ../@processRevision, @name)" />
</xsl:attribute>
<xsl:attribute name="failures">
<xsl:value-of select="@numFailures"/>
</xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="@durationInSeconds"/>
</xsl:attribute>
<xsl:attribute name="tests">
<xsl:value-of select="@numTests"/>
</xsl:attribute>
<xsl:attribute name="errors">
<xsl:value-of select="0"/>
</xsl:attribute>
<properties>
<xsl:for-each select="../ns0:properties/ns0:property">
<property>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@value"/>
</xsl:attribute>
</property>
</xsl:for-each>
<property>
<xsl:attribute name="name">
<xsl:value-of select="'run.start.date'"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="../@startDate"/>
</xsl:attribute>
</property>
<property>
<xsl:attribute name="name">
<xsl:value-of select="'run.end.date'"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="../@endDate"/>
</xsl:attribute>
</property>
<property>
<xsl:attribute name="name">
<xsl:value-of select="'suite.start.date'"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@startDate"/>
</xsl:attribute>
</property>
<property>
<xsl:attribute name="name">
<xsl:value-of select="'suite.end.date'"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@endDate"/>
</xsl:attribute>
</property>
</properties>
<xsl:for-each select=".//ns0:testResult">
<testcase>
<xsl:attribute name="name">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.testToClass(@testName)"/>
</xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="@durationInSeconds"/>
</xsl:attribute>
<xsl:attribute name="classname">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.testToQualifiedClass($packageFormat, @domain, @processName, @processRevision, @testName)"/>
</xsl:attribute>
<xsl:for-each select=".//ns0:executionError">
<failure>
<xsl:attribute name="type">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getExecutionErrorTitle()"/>
</xsl:attribute>
<xsl:attribute name="message">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getExecutionErrorMessage(.)"/>
</xsl:attribute>
</failure>
</xsl:for-each>
<xsl:for-each select=".//ns0:xmlAssertion">
<xsl:if test="(@passed = "false") or (@wasExecuted = "false")">
<failure>
<xsl:attribute name="type">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getFailureType(@wasExecuted, @fatal)"/>
</xsl:attribute>
<xsl:attribute name="message">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getXMLFailureMessage(local-name(..), ../@instanceRefID, ../@testName, @wasExecuted, @fatal, utd:message, @activityName, @variableName, @partName, utd:actualPath, @iteration)"/>
</xsl:attribute>
</failure>
<xsl:for-each select="ns0:xmlDiff">
<failure>
<xsl:attribute name="type">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getXMLDiffType()"/>
</xsl:attribute>
<xsl:attribute name="message">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getXMLDiffMessage(.)"/>
</xsl:attribute>
</failure>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
<xsl:for-each select=".//ns0:valueAssertion">
<xsl:if test="(@passed = "false") or (@wasExecuted = "false")">
<failure>
<xsl:attribute name="type">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getFailureType(@wasExecuted, @fatal)"/>
</xsl:attribute>
<xsl:attribute name="message">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getFailureMessage(local-name(..), ../@instanceRefID, ../@testName, @wasExecuted, @fatal, utd:message, @activityName, @variableName, @partName, utd:actualPath, utd:expected,ns0:actualValue, @iteration)"/>
</xsl:attribute>
</failure>
</xsl:if>
</xsl:for-each>
<xsl:for-each select=".//ns0:activityAssertion">
<xsl:choose>
<xsl:when test="@passed = "false"">
<failure>
<xsl:attribute name="type">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getActivityAssertionTitle()"/>
</xsl:attribute>
<xsl:attribute name="message">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getActivityAssertionMessage(local-name(..), ../@instanceRefID, ../@testName, @activityName, ns0:expectedExecutionCount, ns0:actualExecutionCount)"/>
</xsl:attribute>
</failure>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</testcase>
</xsl:for-each>
</testsuite>
</xsl:for-each>
<!-- *************************
begin code coverage logic
************************* -->
<xsl:if test="$minCodeCoverage > 0">
<testsuite>
<xsl:attribute name="name">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getCoverageSuiteName($packageFormat, ns0:testRunResults/@domain, ns0:testRunResults/@processName, ns0:testRunResults/@processRevision)" />
</xsl:attribute>
<xsl:attribute name="failures">
<!-- count( (if the main process coverage is too low) + (number of sub process's with insufficient coverage) ) -->
<xsl:value-of select="count(/ns0:testRunResults/ns0:codeCoverage[@processName = /ns0:testRunResults/@processName and @processRevision = /ns0:testRunResults/@processRevision and $minCodeCoverage > @coverage] | /ns0:testRunResults/ns0:codeCoverage[(@processName != /ns0:testRunResults/@processName or @processRevision != /ns0:testRunResults/@processRevision) and $minPartnerCodeCoverage > @coverage])"/>
</xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="'0'"/>
</xsl:attribute>
<xsl:attribute name="tests">
<xsl:choose>
<xsl:when test="$minPartnerCodeCoverage = 0">
<xsl:value-of select="1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(/ns0:testRunResults/ns0:codeCoverage)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="errors">
<xsl:value-of select="'0'"/>
</xsl:attribute>
<properties>
<xsl:for-each select="/ns0:testRunResults/ns0:properties/ns0:property">
<property>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@value"/>
</xsl:attribute>
</property>
</xsl:for-each>
<property>
<xsl:attribute name="name">
<xsl:value-of select="'required.coverage'"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="$minCodeCoverage"/>
</xsl:attribute>
</property>
<xsl:if test="$minPartnerCodeCoverage > 0">
<property>
<xsl:attribute name="name">
<xsl:value-of select="'required.subprocess.coverage'"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="$minPartnerCodeCoverage"/>
</xsl:attribute>
</property>
</xsl:if>
</properties>
<xsl:for-each select="/ns0:testRunResults/ns0:codeCoverage">
<xsl:choose>
<xsl:when test="@processName = /ns0:testRunResults/@processName and @processRevision = /ns0:testRunResults/@processRevision">
<testcase>
<xsl:attribute name="name">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getCoverageTestName($packageFormat, @domain, @processName, @processRevision)"/>
</xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="'0'"/>
</xsl:attribute>
<xsl:attribute name="classname">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.coverageTestToQualifiedClass($packageFormat, @domain, @processName, @processRevision)"/>
</xsl:attribute>
<xsl:if test="@coverage < $minCodeCoverage">
<failure>
<xsl:attribute name="type">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getCoverageTitle()"/>
</xsl:attribute>
<xsl:attribute name="message">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getCoverageMessage($minCodeCoverage, @coverage)"/>
</xsl:attribute>
</failure>
</xsl:if>
</testcase>
</xsl:when>
<xsl:when test="$minPartnerCodeCoverage > 0">
<testcase>
<xsl:attribute name="name">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getCoverageTestName($packageFormat, @domain, @processName, @processRevision)"/>
</xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="'0'"/>
</xsl:attribute>
<xsl:attribute name="classname">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.coverageTestToQualifiedClass($packageFormat, @domain, @processName, @processRevision)"/>
</xsl:attribute>
<xsl:if test="@coverage < $minPartnerCodeCoverage">
<failure>
<xsl:attribute name="type">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getCoverageTitle()"/>
</xsl:attribute>
<xsl:attribute name="message">
<xsl:value-of select="java:com.collaxa.cube.ant.taskdefs.BpelTest.getCoverageMessage($minPartnerCodeCoverage, @coverage)"/>
</xsl:attribute>
</failure>
</xsl:if>
</testcase>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</testsuite>
</xsl:if>
</testsuites>
</xsl:template>
</xsl:stylesheet>
the classloader seems to want to make callbacks to the BpelTest methods in order to generate the xml file for junit.
any help on this would be greatly appreciated,I'm having almost the same issue so I was hoping the xalan jars solution would resolve it, but even with the jars copied to the directory and renamed as instructed, the error still occurs when the ant bpeltest task tries to transform the test results into junit format. The error message I'm getting is slightly different but issue seems to be the same. The error message I'm getting is:
[bpeltest] ERROR: 'null'
[bpeltest] FATAL ERROR: 'Could not compile stylesheet'
[bpeltest] javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
[bpeltest] at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
...etc...
BUILD FAILED
C:\projects\jdev_user_home_10g\mywork\BPELTests\BPELTest1\build.xml:179: An error occurred while translating the test results to JUnit results.
Could not compile stylesheet
Please verify the XSL:
bpeltest-junit.xsl
The original XML results have been saved in... ...etc...
Using filemon, I can see where the ant javaw.exe process is reading bpeltest-format.xsl but bpeltest-junit.xsl is never read from the file system (although it could be getting loaded via classloader from orabpel-ant.jar as previously mentioned.) Either way, it doesn't seem like bpeltest-junit.xsl is actually missing.
The error message does not indicate what was null and the references passed to the TransformerFactory are controlled by the bpeltest ant task code so I don't know what's missing.
Anyone have a clue what might be 'null'? Anyone know how to get it fixed? Anyone have a suggestion for a way to a dig up more context and figure out what's missing?
-R -
Data from two tables in the same row in XML transformation
Hi,
I am using XML transformation for generating excel file which is to besent as email attachment.
Here I want to display the data from two internal tables in the same row in the excel. .I am using <tt:loop ref=".<table name>"> ... </tt:loop> for looping through the table. Can I loop two table simultaneously ? In that case how will I specify the fields in each table . Some of the fields in two tables are of same name and type.
Please help...
Thanks,
JissaHello Brian,
Thank you for your answer. It is approach I will use, I think. However let me ask: Would it be possible to have a Version in this layout, too? I mean to see, which value comes from Version A and which comes from Version B? Something like this:
Calendar Month Version Sales Amount
2011.01 B 200
2011.02 B 300
2011.03 A 260
2011.04 A 230
2011.05 A 200
A -
XML Transformation Problem in JDeveloper 10.1.3
I am trying to transform an XML using an XSL, by a Java program, which uses javax.xml.transform.Transformer.
I have a Java project which has the above said program, where when i run the program, the xml transformation is done successfully.
But I have a Web project created, where i have the java project's jar in the WEB-INF/lib. And, when i tried to access the same java program from inside the web project, I am getting the following error:
XML-22000: (Fatal Error) Error while parsing XSL file (unknown protocol: c).
Please help in resolving this error.This is from Metalink:
Cause
This is caused by a conflict between the Oracle XML parser installed by default in OC4J and the
Xerces parser that the application was developed with. Under 10.1.3 OC4J it is possible to tell OC4J not to use the default XML parser for the application at deployment time.
Solution
1. Undeploy the existing application using AS Console.
2. Start a new deployment of the application in AS Console. Click deploy
3. On the Deploy: Select Archive screen, browse to your deployment war file. Click Next
4. On the Deploy: Application Attributes give the application a name and click next
5. On the Deploy: Deployment Settings screen, click the pencil "Go To Task" Icon for the Configure Class Loading option.
6. Locate the shared library called "oracle.xml" (You may need to click "next 10" one or many times depending on the number of shared libraries you have) . For this row, UNCHECK the box for the column "IMPORT". Click OK
7. Click deploy, then test you application. -
Hi all,
I am learning XPATH and XQUERY from the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles, (published by apress). I copied the Code Listing 12-8 FOR XML PATH Using XPath Node Tests (listed below) and executed it in my
SQL Server 2012 Management Studio:
--Coles12_8.sql // saved in C:/Documemnts/SQL Server Management Studio
-- Coles Listing 12-8 FOR XML PATH Using XPATH Node Tests
-- Retrieving Name and E-mail Addresses with FOR XML PATH in AdvantureWorks
-- 16 March 2015 0935 AM
USE AdventureWorks;
GO
SELECT
p.NameStyle AS "processing-instruction(nameStyle)",
p.BusinessEntityID AS "Person/@ID",
p.ModifiedDate AS "comment()",
pp.PhoneNumber AS "test()",
FirstName AS "Person/Name/First",
MiddleName AS "Person/Name/Middle",
LastName AS "Person/Name/Last",
EmailAddress AS "Person/Email"
FROM Person.Person p
INNER JOIN Person.EmailAddress e
ON p.BusinessEntityID = e.BusinessEntityID
INNER JOIN Person.PersonPhone pp
ON p.BusinessEntityID = pp.BusinessEntityID
FOR XML PATH;
I got the following error message:
Msg 6850, Level 16, State 1, Line 2
Column name 'test()' contains an invalid XML identifier as required by FOR XML; '('(0x0028) is the first character at fault.
I have no ideas why I got this error message. Please kindly help and advise me how to resolve this error.
Thanks in advance, Scott ChangHi Michelle, Thanks for your nice response.
I corrected the mistake and executed the revised code. It worked nicely.
I just have one question to ask you about the appearance of the xml output of my Co;les12_8.sql:
<row>
<?nameStyle 0?>
<Person ID="1" />
<!--2003-02-08T00:00:00-->697-555-0142<Person><Name><First>Ken</First><Middle>J</Middle><Last>Sánchez</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="2" />
<!--2002-02-24T00:00:00-->819-555-0175<Person><Name><First>Terri</First><Middle>Lee</Middle><Last>Duffy</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="3" />
<!--2001-12-05T00:00:00-->212-555-0187<Person><Name><First>Roberto</First><Last>Tamburello</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="4" />
<!--2001-12-29T00:00:00-->612-555-0100<Person><Name><First>Rob</First><Last>Walters</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="5" />
<!--2002-01-30T00:00:00-->849-555-0139<Person><Name><First>Gail</First><Middle>A</Middle><Last>Erickson</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="6" />
<!--2002-02-17T00:00:00-->122-555-0189<Person><Name><First>Jossef</First><Middle>H</Middle><Last>Goldberg</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="7" />
<!--2003-03-05T00:00:00-->181-555-0156<Person><Name><First>Dylan</First><Middle>A</Middle><Last>Miller</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="8" />
<!--2003-01-23T00:00:00-->815-555-0138<Person><Name><First>Diane</First><Middle>L</Middle><Last>Margheim</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="9" />
<!--2003-02-10T00:00:00-->185-555-0186<Person><Name><First>Gigi</First><Middle>N</Middle><Last>Matthew</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="10" />
<!--2003-05-28T00:00:00-->330-555-2568<Person><Name><First>Michael</First><Last>Raheem</Last></Name><Email>[email protected]</Email></Person></row>
<row>
<?nameStyle 0?>
<Person ID="11" />
<!--2004-12-29T00:00:00-->719-555-0181<Person><Name><First>Ovidiu</First><Middle>V</Middle><Last>Cracium</Last></Name><Email>[email protected]</Email></Person></row>
<row>
I feel this xml output is not like the regular xml output. Do you know why it is diffrent from the regular xml xml output? Please comment on this matter.
Thanks,
Scott Chang
What do you mean by regular xml document? Are you referring to fact that its missing a root element? if yes it can be added as below
USE AdventureWorks;
GO
SELECT
p.NameStyle AS "processing-instruction(nameStyle)",
p.BusinessEntityID AS "Person/@ID",
p.ModifiedDate AS "comment()",
pp.PhoneNumber AS "text()",
FirstName AS "Person/Name/First",
MiddleName AS "Person/Name/Middle",
LastName AS "Person/Name/Last",
EmailAddress AS "Person/Email"
FROM Person.Person p
INNER JOIN Person.EmailAddress e
ON p.BusinessEntityID = e.BusinessEntityID
INNER JOIN Person.PersonPhone pp
ON p.BusinessEntityID = pp.BusinessEntityID
FOR XML PATH('ElementName'),ROOT('RootName');
replace ElementName and RootName with whatever name you need to set for element as well as the root element
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Hi all
In my other thread "javax.xml.transform." last replied to on 17/04/05, I described that having & in my xml was causing TransformerExceptions when I attempted to apply a stylesheet to the xml.
I've now deployed exactly the same xml, xsl and java on a completely different environment and have found that the error does NOT occur.
This completely baffled me at first, but then I read the following in the API documentation for TransformerFactory: -
"A TransformerFactory instance can be used to create Transformer and Templates objects.
The system property that determines which Factory implementation to create is named "javax.xml.transform.TransformerFactory". This property names a concrete subclass of the TransformerFactory abstract class. If the property is not defined, a platform default is be used.
I think that the key must lie in the system property "javax.xml.transform.TransformerFactory". The two environments must be using a different value for this - one representing a class that objects to & and one that doesn't. In neither case do I actually set this property, so my main question is what does it default to and how can I find out what each environment is using for this?
I'm really baffled here guys, any help would be massively appreciated.
Thank you
Jonjavax.xml.transform.TransformerFactory is a real class implemented by someone. It looks at the system property to figure out what actual implementation to use. It the property doesn't exist, it uses the class that came bundled with the javax.xml.transform.TransformerFactory class you are using.
Here, for instance, is the javax.xml.transform.TransformerFactory that comes with jdk1.4.2
public static TransformerFactory newInstance()
throws TransformerFactoryConfigurationError
try {
return (TransformerFactory) FactoryFinder.find(
/* The default property name according to the JAXP spec */
"javax.xml.transform.TransformerFactory",
/* The fallback implementation class name */
"org.apache.xalan.processor.TransformerFactoryImpl");
} catch (FactoryFinder.ConfigurationError e) {
throw new TransformerFactoryConfigurationError(e.getException(),
e.getMessage());
} -
Fatal Error and NullPointerException in Oracle XML Transformer
Hi,
I'm building a dom tree in memory with oracle xml parser. Then I transform the dom document into a string to send xml to the client. But I get an fatal error on calling transform.
I don't know what could be the problem, because apache and weblogic parser works, an when I create a dom document with org.w3c.dom elements and statements then the xml document can't be invalid,
because the document implementation would throw an exception if wrong nodes or something like this should be inserted...
I'm using oracle xml parser 9.2.0.4 for java, bea weblogic 7.0 and win2k.
Thanks for help.
XSL-1900: (Fatal Error) An internal error condition occurred.
javax.xml.transform.TransformerException: XSL-1900: (Fatal Error) An internal error condition occurred.
at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:681)
at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:309)
java.lang.NullPointerException
at oracle.xml.parser.v2.XSLSAXPrintDriver.printAttributes(XSLSAXPrintDriver.java:394)
at oracle.xml.parser.v2.XSLSAXPrintDriver.startElement(XSLSAXPrintDriver.java:322)
at oracle.xml.parser.v2.XMLElement.reportSAXEvents(XMLElement.java:993)
at oracle.xml.parser.v2.XMLNode.reportChildSAXEvents(XMLNode.java:1014)
at oracle.xml.parser.v2.XMLDocument.reportSAXEvents(XMLDocument.java:942)
at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:294)Hi,
I'm having that problem to:
I'm getting the following exception
javax.xml.transform.TransformerException: XSL-1900: (Fatal Error) An internal error condition occurred.
at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:723)
at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:340)
at com.ac.mqif.control.Handler.handleLong(Handler.java:835)
at com.ac.mqif.control.Handler.run(Handler.java:951)
Caused by: java.lang.NullPointerException
at oracle.xml.parser.v2.XPathStep.getSelectedNodes(XPathStep.java:380)
at oracle.xml.parser.v2.PathExpr.getValue(XSLNodeSetExpr.java:483)
at oracle.xml.parser.v2.XSLExprBase.getStringValue(XSLExprBase.java:363)
at oracle.xml.parser.v2.XSLValueOf.processAction(XSLValueOf.java:99)
at oracle.xml.parser.v2.XSLNode.processChildren(XSLNode.java:367)
at oracle.xml.parser.v2.XSLTemplate.processAction(XSLTemplate.java:199)
at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:214)
at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:207)
at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:207)
at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:120)
at oracle.xml.parser.v2.XSLNode.processChildren(XSLNode.java:367)
at oracle.xml.parser.v2.XSLTemplate.processAction(XSLTemplate.java:199)
at oracle.xml.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:471)
at oracle.xml.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:448)
at oracle.xml.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:246)
at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:327)
... 2 more
when using a stylesheet which has a template match condition of more than 1600 characters.
The second thing is that the Oracle XML transformer is
NOT threadsafe. I was using several threads using different templates to transform an incoming XML simultaneously but was ALWAYS getting internal XSL errors
and Nullpointer Exceptions. I solved this by synchronizing the transformation, but I don't like it.
I'm using the following versions on Windows XP:
Oracle IDE: 9.0.3.10.35
Business Components Version: 9.0.3.10.7
SCM Support Version: 9.0.3.9.4
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Thanx,
Ellcrys -
Create XML transformation in SAP R/3 4.7
Hi Experts,
Kindly let me know the transaction for creating xml transformation in sap r/3 4.7, if there is any.
Though i could not find anything through tstc or se93.
Is there any other way of creating xml transformation in r/3 4.7. There is a tcode STRANS in ecc6.0 but not in 4.7.
Also, please help me resolving this issue of converting abap data to xml file: -
is the following xml structure possible with transformation or by any other method.
<Process_Order>
<item>
<PO Number> PO123334 </PO Number>
<Header_mat> Mat123 </Header_mat>
<BOM>
<PDLabels>
<PDLabel>
<PCode>P123456</PCode>
<Batch>123ABC</Batch>
<Quantity>6000</Quantity>
<PDDCode>1234567890</PDDCode>
</PDLabel>
<PDLabel>
<PCode>P234567</PCode>
<Batch>567DEF</Batch>
<Quantity>6000</Quantity>
<PDDCode></PDDCode>
</PDLabel>
</PDLabels>
<PDCartons>
<PDCarton>
<PCode>P556677</PCode>
<Batch>589GFT</Batch>
<Quantity>1200</Quantity>
<PDDCode></PDDCode>
</PDCarton>
</PDCartons>
</BOM>
</item>
<item>
<PO Number> PO123334 </PO Number>
<Header_mat> Mat123 </Header_mat>
<BOM>
<PDLabels>
<PDLabel>
<PCode>P123456</PCode>
<Batch>123ABC</Batch>
<Quantity>6000</Quantity>
<PDDCode>1234567890</PDDCode>
</PDLabel>
<PDLabel>
<PCode>P234567</PCode>
<Batch>567DEF</Batch>
<Quantity>6000</Quantity>
<PDDCode></PDDCode>
</PDLabel>
</PDLabels>
<PDCartons>
<PDCarton>
<PCode>P556677</PCode>
<Batch>589GFT</Batch>
<Quantity>1200</Quantity>
<PDDCode></PDDCode>
</PDCarton>
</PDCartons>
</BOM>
</item>
</Process_Order>
What i mean to ask is, is the hierarchy to this structural level is attainable using either transfomation or any other alternative.
Thanks a lot in advance !
Shreyaoops the message structure has gone bad ........
What i meant was : --
<Process_Order>
<item>
<PO Number> PO123334 </PO Number>
<Header_mat> Mat123 </Header_mat>
<BOM>
<PDLabels>
<PDLabel>
<PCode>P123456</PCode>
<Batch>123ABC</Batch>
<Quantity>6000</Quantity>
<PDDCode>1234567890</PDDCode>
</PDLabel>
<PDLabel>
<PCode>P234567</PCode>
<Batch>567DEF</Batch>
<Quantity>6000</Quantity>
<PDDCode></PDDCode>
</PDLabel>
</PDLabels>
<PDCartons>
<PDCarton>
<PCode>P556677</PCode>
<Batch>589GFT</Batch>
<Quantity>1200</Quantity>
<PDDCode></PDDCode>
</PDCarton>
</PDCartons>
</BOM>
</item>
</Process_Order> -
XSL problem with javax.xml.transform.sax.SAXTransformerFactory
Dear sirs,
I use SAXTransformerFactory in order to transform a Hashtable to SAX Event and apply a XSL.
I try this code with the lastest version of apache parser.
It run well.
But, I put this software to WEBLOGIC 6.2 server and no run.
this check is true:
if (transFact.getFeature(javax.xml.transform.sax.SAXTransformerFactory.FEATURE)&&transFact.getFeature(javax.xml.transform.sax.SAXSource.FEATURE))
Some one can help me.
Thank in avance
The code:
java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
com.cajarural.xml.HashtableParser parser = new com.cajarural.xml.HashtableParser(hashtable);
// Codigo para el TansformerHandler
// set the destination for the XSLT transformation
javax.xml.transform.TransformerFactory transFact = javax.xml.transform.TransformerFactory.newInstance();
if (transFact.getFeature(javax.xml.transform.sax.SAXTransformerFactory.FEATURE)&&transFact.getFeature(javax.xml.transform.sax.SAXSource.FEATURE))
javax.xml.transform.sax.SAXTransformerFactory saxTransFact = (javax.xml.transform.sax.SAXTransformerFactory) transFact;
javax.xml.transform.sax.TransformerHandler transHand = saxTransFact.newTransformerHandler(templates);
transHand.setResult(new javax.xml.transform.stream.StreamResult(bout));
parser.setContentHandler(transHand);
// attach the XSLT processor to the parser.parse();
return new String(bout.toByteArray());put Xalan in your war file then try using this kind of commands: System.setProperty("org.xml.sax.parser", "org.apache.xerces.parsers.SAXParser");
System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");This tells JAXP what implementations it should use without even asking your administrator to modify the WebLogic setup...
It's what I've done with the WLS7.0 server I am using ;-) -
Styling XML with XSLT Problem with javax.xml.transform???
I have been trying to make a transformation and seem to be having a problem in that javax.xml.transform can not be found while using jdk1.3....If I use jdk1.4, there is no problem....
Does anyone know how I can get things to work using jdk1.3???
(Description of what I am doing...1) Building XML Source 2) Setting up the XSLT File 3) Building Source Object 4) Build Result Object 5) Transforming the Data.....MY RESULT SHOULD BE AN HTML PAGE)
I have tried putting xerces.jar and xalan.jar in my CLASSPATH....but this still doesn't work....onyl thing that has worked is using jdk1.4 as my JAVA_HOME....
PLEASE HELP!!!!PLEASE HELP....your advice here would be greatly appreciated.....
-
Javax.xml.transform.TransformerException durin XSL Transformation in Java
Hi,
Below is my piece of code where i access a web service that returns a xml as a string. I apply a xsl tranformation on it and try to store the result as a string. I get this error message
javax.xml.transform.TransformerException: Result object passed to ''{0}'' is invalid.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at NewService.main(NewService.java:52)My Code:
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class NewService {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
String endPoint = "http://localhost:8080/SampleDynamicWebProj/services/SampleClient";
Service service = new Service();
Call callOne;
try {
callOne = (Call) service.createCall();
callOne.setTargetEndpointAddress(new URL(endPoint));
callOne.setOperationName(new QName("http://DefaultNamespace",
"getXMLString"));
String concated = (String) callOne.invoke(new Object[] { "s" });
InputStream xsltFile = new FileInputStream("xslpackage/empTran.xsl");
Source xmlSource = new StreamSource(new StringReader(concated));
Source xsltSource = new StreamSource(xsltFile);
TransformerFactory transFact =
TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
Result result = new StreamResult();
trans.transform(xmlSource, result);
System.out.println(result.toString());
} catch (ServiceException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (TransformerConfigurationException e) {
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
}I get the transformed XML into a Result object, but when i do a toString() oon it, i get the above exception.
any help wil be appreciated,
DilipOh well, yes it was a typo in address tag...ok agreed that its a bad example, check this out then,
i have a XML data that i convert to a html format using xsl transformation, now this converted html has to be shown in a html page(i use the out.write option).
so my initial xml looks like this ::
<?xml version="1.0" encoding="ISO-8859-1"?>
<Results>
<ColumnCount>6</ColumnCount>
<Columns>
<column>UID</column>
<column>UserName</column>
<column>Password</column>
<column>LastName</column>
<column>FirstName</column>
<column>EmailAddress</column>
</Columns>
<Rows>
<Row>
<value>1</value>
<value>userone</value>
<value>password-1</value>
<value>Anant</value>
<value>Dilip</value>
<value>[email protected]</value>
</Row>
<Row>
<value>2</value>
<value>usertwo</value>
<value>password-2</value>
<value>Palli</value>
<value>Gilli</value>
<value>[email protected]</value>
</Row>
</Rows>I apply XSL transformation on this to get a HTML which i will be writing into my output screen hoping that the user will see it in a tabular format!
<[!CDATA["
<?xml version="1.0" encoding="UTF-8"?>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">UID</th>
<th align="left">UserName</th>
<th align="left">Password</th>
<th align="left">LastName</th>
<th align="left">FirstName</th>
<th align="left">EmailAddress</th>
</tr>
<tr>
<td>1</td>
<td>userone</td>
<td>password-1</td>
<td>Anant</td>
<td>Dilip</td>
<td>[email protected]</td>
</tr>
<tr>
<td>2</td>
<td>usertwo</td>
<td>password-2</td>
<td>Palli</td>
<td>Gilli</td>
<td>[email protected]</td>
</tr>
</table>
"]]>The entire data is passed to a XML parser . I want the transformed xml data (which will be inside a <status></status> tag to be untouched by this parser. As you see i have put the transformed xml in a CDATA tag, but this aint helping me...
need urgent help,
Dilip -
Hi,
I have a scenario where I need to perform an XML to XML transformation and I need to do this using XSLT mapping.
I am using XMLSpy.
Could somebody help me on this issue?Any weblogs that can help me on this?
regards,
PrashanthHi Prashanth,
You can do the xsl transformation in XMLSpy itself.First create your source xml file in XMLSpy by selecting file type as xml.After that create your xslt program file by selecting file type as xslt.
Then you can use the xslt program for transformation of source xml into target xml by choosing menu XSL/XQuery->XSL Transformation.
sample xsl code for an example:
source xml structure:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<header>
<detail>
Detail1
</detail>
<detail>
Detail2
</detail>
</header>
<header>
<detail>
Detail3
</detail>
</header>
</root>
xsl program:
<xsl:stylesheet version = '1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<root>
<xsl:for-each select="//header">
<idoc>
<xsl:for-each select="detail">
<detail>
<xsl:value-of select="."/>
</detail>
</xsl:for-each>
</idoc>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
target xml structure:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<idoc>
<detail>
Detail1
</detail>
<detail>
Detail2
</detail>
</idoc>
<idoc>
<detail>
Detail3
</detail>
</idoc>
</root>
Hope this would help.
Rgds
Sudhakar.
Maybe you are looking for
-
Is there a way to set "Artist List" view as the default view for all playlists? There has to be a default setting somewhere so that you don't have to go through every single playlist and manually change it, right? Thanks!
-
To open a Excel and Doc file inside the AIR application
How to open a Excel and Doc file inside the AIR application. I have opened the PDF file inside the AIR application. But i got stuck in opening the Exce and Doc file. Please help me in this issue.
-
10.8.2 update and 2880 epson printer
10.8.2 update and 2880 epson printer filter error The news update has removed all connection with the printer Help
-
Dear Experts, Is it possible to add a Key Figure in the report without adding in the Query Design? Kindly provide the steps. Regards KV
-
I have a W500 running windows 32bit and I was hoping to upgrade my old HDD (500 GB) to a new one (750GB) and keep the R&R partition at the end. To make sure I had the latest version, I uninstalled and reinstalled R&R. (v 4.31) I then ran R&R from w