XSLT Transform in XML Signature: Exception
Hello,
I have following problem with an XSLT tranform in my XML signature. Here is the code I use to add XSLT to signature:
main() {
DOMStructure stylesheet = new DOMStructure( getStylesheet() );
XSLTTransformParameterSpec spec = new XSLTTransformParameterSpec( stylesheet );
transforms.add( fac.newTransform( Transform.XSLT, spec ) );
private Element getStylesheet() throws Exception {
String stylesheet = //"<?xml version=\"1.0\"?>" +
"<xslt:stylesheet version=\"1.0\" xmlns:xslt=\"http://www.w3.org/1999/XSL/Transform\">\n" +
" <xsl:include href=\"http://extern XSLT\" />\n" +
" <xslt:template match=\"/\">" +
" <xsl:apply-imports />" +
" </xslt:template>" +
"</xslt:stylesheet>\n";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//dbf.setValidating( true );
return dbf.newDocumentBuilder().parse( new ByteArrayInputStream( stylesheet.getBytes() ) ).getDocumentElement();
I get following exception:
javax.xml.crypto.dsig.XMLSignatureException: javax.xml.crypto.dsig.TransformException: com.sun.org.apache.xml.internal.security.transforms.TransformationException: Cannot find xslt:stylesheet in Transform
Original Exception was com.sun.org.apache.xml.internal.security.transforms.TransformationException: Cannot find xslt:stylesheet in Transform
at org.jcp.xml.dsig.internal.dom.DOMReference.transform(Unknown Source)
at org.jcp.xml.dsig.internal.dom.DOMReference.digest(Unknown Source)
at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.digestReference(Unknown Source)
at org.jcp.xml.dsig.internal.dom.DOMXMLSignature.sign(Unknown Source)
In google I cannot find any details what can be wrong.
Any suggestions?
Thanks in advance,
errno
Thanks for your response. Sorry - I tried both versions with xslt and xsl - doesn't worked -> the error in my post is actually caused through the multiple changes of this part of code. Here once again:
private Element getStylesheet() throws Exception {
String stylesheet = //"<?xml version=\"1.0\"?>" +
"<xslt:stylesheet version=\"1.0\" xmlns:xslt=\"http://www.w3.org/1999/XSL/Transform\">\n" +
" <xslt:include href=\"external XSLTl\" />\n" +
" <xslt:template match=\"/\">" +
" <xslt:apply-imports />" +
" </xslt:template>" +
"</xslt:stylesheet>\n";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//dbf.setValidating( true );
return dbf.newDocumentBuilder().parse( new ByteArrayInputStream( stylesheet.getBytes() ) ).getDocumentElement();
Thanks,
errno
Similar Messages
-
XSLT transformation in XML to ABAP: special characters issue
Hi,
I am parsing well-formed XML file that has the following data (:
<projects><project><name>Wallis & Futuna</name></project></projects>
I use XSLT transformation:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="projects">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<PROJECTS>
<xsl:for-each select="project">
<PROJECT>
<NAME>
<xsl:value-of select="name"/>
</NAME>
</PROJECT>
</xsl:for-each>
</PROJECTS>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
If I use the above example without &amp; everything works fine, but the original XML fails with exception CX_XSLT_DESERIALIZATION_ERROR and message "Error during deserialization". Googling around did not give an answer.
Any words of wisdom?
Edited by: Alexei Isaev on Apr 26, 2011 5:04 AM
Edited by: Alexei Isaev on Apr 26, 2011 5:05 AMHi,
Please visit the following link for reference.
http://help.sap.com/abapdocu_70/en/ABAPCALL_TRANSFORMATION.htm
Thanks & Regards,
Harish -
BI Admin Tool and XSLT transformation for XML data source - How it works ?
Hello,
There is a possibility to import data from XML data source using BI Admin Tool.
In the import window we can point XSLT file. What is the purpose of that XSLT field?
Why I am asking ?
I thought it is smth like XSLT processor, but simply it doesnt work.
What I did:
- I pointed XML data source file
- I pointed XSLT transformation file
- Click OK, and still get the message that the XML file structure is not supported
After that I transformed that XML file with some desktop XSLT processor using the same XSLT file, and I tried to connect that file directly using BI Admin tool.Then it works. So it means that the transformation is ok.
So basically one question comes to my mind in that situation:
What is the purpose of XSLT field in BI Admin Tool when it comes to XML data source ?
(it doesnt look like XSLT processor)
Greetings
/MichalHi Mariano
Why you need to use XSLT for transforming XML file into ABAP table
Code is a part of some ABAP report. Looks like it is reading a file from file system and updating table after transformation
If you have requirement like you need to read XML file and then insert the data into a SAP table
You can use
File to RFC
File to Proxy scenario using SAP PI.
Please provide more inputs on requirement to help
Thanks
Gaurav -
XSLT transformation for XML to ABAP internal table
Hi, can anyone please tell me how it should be the xslt tranformation to conver this xml
<Embargos_ARBA_DOC>
<ns:Embargos_ARBA_MT
xmlns:ns="un:swissmedical:sap:proxy:embargos_arba:file">
<Embargos_ARBA_MT>
<FECHA>20081101</FECHA>
<CUIT>50000002124</CUIT>
<MONTO>0000013794090</MONTO>
<RAZON_SOCIAL>RAUL ARMANDO CUNQUEIRO S.A.C.I.</RAZON_SOCIAL>
</Embargos_ARBA_MT>
<Embargos_ARBA_MT>
<FECHA>20081101</FECHA>
<CUIT>55000001456</CUIT>
<MONTO>0000001144410</MONTO>
<RAZON_SOCIAL>PARODI ESTEBAN ARMANDO</RAZON_SOCIAL>
</Embargos_ARBA_MT>
</ns:Embargos_ARBA_MT>
</Embargos_ARBA_DOC>
to this abap Table....
DATA: BEGIN OF i_embargos_arba_doc occurs 0,
fecha TYPE d,
cuit TYPE char11,
monto TYPE char13,
razon_social(120),
END OF i_embargos_arba_mt.
so i can transform it with this sentence
CALL TRANSFORMATION ('embargos_transformation')
SOURCE XML source
RESULT Embargos_ARBA_DOC = embargos.
pls i need help because i am unable to create this xslt transformation...
I will give the highest rewards points to the one who can help me.
thanks!
marianoHi Mariano
Why you need to use XSLT for transforming XML file into ABAP table
Code is a part of some ABAP report. Looks like it is reading a file from file system and updating table after transformation
If you have requirement like you need to read XML file and then insert the data into a SAP table
You can use
File to RFC
File to Proxy scenario using SAP PI.
Please provide more inputs on requirement to help
Thanks
Gaurav -
XSLT transformation of XML string
Hello Everyone,
This is my first endeavor to use XSLT and XML in our newly upgraded system. I can't for the life of me figure out what is wrong with my code and would appreciate someone just glancing over it and pointing out what is likely a realy dumb problem.
I have a program that reads a PEXR2002 IDoc. For testing purposes, I've hardcoded that IDoc number. It runs fine, creates the XML fine, the xslt in STRANS tests fine as well...but in the end my ls_table is blank. I've been fuddling with this for a while and would really appreciate another pair of eyes taking a look at it.
THANKS!!
Greg
My program. (xslt is below...really simple, but it's my first time).
TYPES: BEGIN OF ty_table,
sndprn LIKE edidc-sndprn,
bgmref TYPE edif1004_r,
moabetr TYPE edif5004_a,
credat TYPE edidat8,
datum TYPE edidat8,
END OF ty_table.
DATA: o_idoc TYPE REF TO cl_idoc_xml1, str type string, ls_table type ty_table.
CREATE OBJECT o_idoc
EXPORTING
docnum = '0000000000211014'.
CALL METHOD o_idoc->get_xmldata_as_string
IMPORTING
data_string = str.
CALL TRANSFORMATION ZUSL_PEXR2002_V1
SOURCE XML str
RESULT HEADER_DATA = ls_table.
My XSLT....
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap version="1.0">
<asx:values>
<HEADER_DATA>
<SNDPRN>
<xsl:value-of select="PEXR2002/IDOC/EDI_DC40/SNDPRN"/>
</SNDPRN>
<BGMREF>
<xsl:value-of select="PEXR2002/IDOC/E1IDKU1/BGMREF"/>
</BGMREF>
<MOABETR>
<xsl:value-of select="PEXR2002/IDOC/E1IDKU5/MOABETR"/>
</MOABETR>
<CREDAT>
<xsl:value-of select="PEXR2002/IDOC/EDI_DC40/CREDAT"/>
</CREDAT>
<DATUM>
<xsl:value-of select="PEXR2002/IDOC/E1EDK03/DATUM"/>
</DATUM>
</HEADER_DATA>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>Hi Greg,
please try it with the following (just slightly) modified transformation (works fine for me):
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:sap="http://www.sap.com/sapxsl"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/PEXR2002/IDOC">
<asx:abap version="1.0">
<asx:values>
<HEADER_DATA>
<SNDPRN>
<xsl:value-of select="EDI_DC40/SNDPRN"/>
</SNDPRN>
<BGMREF>
<xsl:value-of select="E1IDKU1/BGMREF"/>
</BGMREF>
<MOABETR>
<xsl:value-of select="E1IDKU5/MOABETR"/>
</MOABETR>
<CREDAT>
<xsl:value-of select="EDI_DC40/CREDAT"/>
</CREDAT>
<DATUM>
<xsl:value-of select="E1EDK03/DATUM"/>
</DATUM>
</HEADER_DATA>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
I recommend to test all transformations that you define on a sample source and check the output. If you apply your original transformation you would see that it basically doesn't select anything and therefore you just get an XML document with the field names but no values.
Cheers, harald -
XSLT Transformation from XML to CVS format
I am using the following xsl sheet in conjunction with the XSLSample.java application delivered with xdk and cannot get the output I desire. Does Orcales xsl processor output text documents?
XSL:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="ROWSET/ROWS[1]/*" mode="elementNames"/>
<xsl:apply-templates select="ROWSET/ROWS"/>
</xsl:template>
<xsl:template match="*" mode="elementNames">
<xsl:value-of select="name()"/>
<xsl:choose>
<xsl:when test="position() != last()">,</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="ROW">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="*">
<xsl:if test="contains(.,' ')">"</xsl:if>
<xsl:value-of select="."/>
<xsl:if test="contains(.,' ')">"</xsl:if>
<xsl:choose>
<xsl:when test="position() != last()">,</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
XML:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<CUST_ID>1000000009</CUST_ID>
<NAME1>Pineview Preschool</NAME1>
<ITEM>0000000007</ITEM>
<POST_DATE>01/02/2001</POST_DATE>
<ENTRY_TYPE>PY</ENTRY_TYPE>
<DOCUMENT> </DOCUMENT>
</ROW>
<ROW num="2">
<CUST_ID>1000000006</CUST_ID>
<NAME1>Cellular One</NAME1>
<ITEM>0000000008</ITEM>
<POST_DATE>01/02/2001</POST_DATE>
<ENTRY_TYPE>PY</ENTRY_TYPE>
<DOCUMENT> </DOCUMENT>
</ROW>
</ROWSET>
Any help for this xsl beginner would be greatly appreciated.
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steven Muench ([email protected]):
The problem is likely that you are incorrectly using:
[b]DocumentFragment processXSL(xsl,xml)
instead of the other API:
void processXSL(xsl,xml,PrintWriter)
the latter allows the XSLT engine to do its <xsl:output> serialization behavior. The former does not.<HR></BLOCKQUOTE>
Thanks Steve,
I am now doing that. How can I get rid of the top level xml tag that prints out after applying the xsl sheet. I need a simple text file with just the data.
Thanks,
Jeff
null -
XSLT Transformation from XML to ABAP field
Hi all,
How can I retrieve my XML node's value (EMPLOYEE) XML to an ABAP variable (W_KUNNR)
DATA w_kunnr TYPE string.
CONCATENATE
'<services>'
'<Myservice>'
'<APPLICATION>APPLI1</APPLICATION>'
'<SERVICE>SERV1</SERVICE>'
'<TOSAP>'
'<EMPLOYEE>00000036</EMPLOYEE>'
'</TOSAP>'
'</Myservice>'
'</services>'
INTO request.
CALL TRANSFORMATION z_trans
SOURCE XML request
RESULT kunnr = w_kunnr.
thanks.
Edited by: Noureddine MOUTAA on Oct 28, 2008 2:25 PMI did like this:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<KUNNR>
<xsl:value-of select="//services/Myservice/TOSAP/EMPLOYEE"/>
</KUNNR>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform> -
Automatic insert of xmlns:xsl during XSLT transformation
I am using the xmlparserv2.jar of dated "12/10/00" to perform a XSLT transformation. I need to insert a xml:space="preserve" attribute to a generated tag. However, there is an addition attribute added : xmlns:xml="http://www.w3/org/XML/1998/namespace". How can I suppress the generation of this attribute ?
Here is my XML :
<?xml version = '1.0' standalone = 'no'?>
<COLDdoc>
<Page template="bkgnd1" num="1">
<Line num="1"> CN011A021C 1A021</Line>
<Line num="2"> 1954.90 7713.36</Line>
</Page>
</COLDdoc>
My XSL is :
<?xml version = '1.0' standalone = 'yes'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no" doctype-system="svg-20000303-stylable.dtd"/>
<xsl:template match="Line">
<text>
<xsl:attribute name="x">0</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="@num*10"/>
</xsl:attribute>
<xsl:attribute name="xml:space">preserve</xsl:attribute>
<xsl:value-of select="."/>
</text>
</xsl:template>
</xsl:stylesheet>
The result XSLT Transformation :
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE text SYSTEM "svg-20000303-stylable.dtd">
<text x="0" y="10" xmlns:xml="http://www.w3/org/XML/1998/namespace" xml:space="preserve"> CN011A021C 1A021</text>
<text x="0" y="20" xmlns:xml="http://www.w3/org/XML/1998/namespace" xml:space="preserve"> "> 1954.90 7713.36</text>
Regards.
Jeffrey
nullHi Greg,
please try it with the following (just slightly) modified transformation (works fine for me):
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:asx="http://www.sap.com/abapxml"
xmlns:sap="http://www.sap.com/sapxsl"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/PEXR2002/IDOC">
<asx:abap version="1.0">
<asx:values>
<HEADER_DATA>
<SNDPRN>
<xsl:value-of select="EDI_DC40/SNDPRN"/>
</SNDPRN>
<BGMREF>
<xsl:value-of select="E1IDKU1/BGMREF"/>
</BGMREF>
<MOABETR>
<xsl:value-of select="E1IDKU5/MOABETR"/>
</MOABETR>
<CREDAT>
<xsl:value-of select="EDI_DC40/CREDAT"/>
</CREDAT>
<DATUM>
<xsl:value-of select="E1EDK03/DATUM"/>
</DATUM>
</HEADER_DATA>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
I recommend to test all transformations that you define on a sample source and check the output. If you apply your original transformation you would see that it basically doesn't select anything and therefore you just get an XML document with the field names but no values.
Cheers, harald -
Updating XML prior to XSLT transformation
I am attempting to convert an XML document using XSLT but I need to transform it a bit beforehand. Does anyone have a suggestion as to how to do this?
Below is the logic that will transform the XML directly from the file, but I need to manipulate it first.
Thanks in advance.
Patti
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import java.io.*;
public class Transform {
* Performs an XSLT transformation, sending the results
* to System.out.
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println(
"Usage: java Transform [xmlfile] [xsltfile]");
System.exit(1);
File xmlFile = new File(args[0]);
File xsltFile = new File(args[1]);
// JAXP reads data using the Source interface
Source xmlSource = new StreamSource(xmlFile);
Source xsltSource = new StreamSource(xsltFile);
// the factory pattern supports different XSLT processors
TransformerFactory transFact =
TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
trans.transform(xmlSource, new StreamResult(System.out));
}The first scenerio is what I intended. Since I posted my question I realized that I can manipulate the string and then create a StringSource passing a StringReader like so:
StringReader src = new StringReader(xmlStr);
StringWriter target = new StringWriter();
currentTransformer.transform(new StreamSource(src),
new StreamResult(target));Thanks. -
ABAP XSLT transformation - XML to deep structure/nested standard table
Hi all,
I was struggling with this topic recently and couldn't find a single working example or description of a possible solution. So now that I've sorted it out, I did a quick example to elustrate how it works. Here is the code with XML embeded in it and the XSLT follows:
<HR>
<PRE>
*& Report Z_XML2ABAP
*& Author: Jayanta Roy
*& Date: 03/02/2010
REPORT z_xml2abap.
DATA input_xml TYPE string.
TYPES: BEGIN OF t_address,
house_no TYPE string,
street_name TYPE string,
city_name TYPE string,
phone_no TYPE string,
END OF t_address.
TYPES: t_addresses TYPE STANDARD TABLE OF t_address with NON-UNIQUE KEY house_no.
TYPES: BEGIN OF t_person,
firstname TYPE string,
surname TYPE string,
addresses TYPE t_addresses,
END OF t_person.
input_xml = '<Friends>' &&
'<People>' &&
'<FirstName>Homer</FirstName>' &&
'<Surname>Simpson</Surname>' &&
'<Address>' &&
'<HouseNo>123</HouseNo>' &&
'<Street>Evergreen Terrace</Street>' &&
'<City>Springfield</City>' &&
'<PhoneNo>011212321</PhoneNo>' &&
'</Address>' &&
'<Address>' &&
'<HouseNo>7G</HouseNo>' &&
'<Street>Neuclear Power Plant</Street>' &&
'<City>Spring Field</City>' &&
'<PhoneNo>911</PhoneNo>' &&
'</Address>' &&
'</People>' &&
'<People>' &&
'<FirstName>Bart</FirstName>' &&
'<Surname>Simpson</Surname>' &&
'<Address>' &&
'<HouseNo>123x</HouseNo>' &&
'<Street>Evergreen Terracex</Street>' &&
'<City>Springfieldx</City>' &&
'<PhoneNo>011212321x</PhoneNo>' &&
'</Address>' &&
'</People>' &&
'</Friends>' .
DATA lt_person TYPE STANDARD TABLE OF t_person.
TRY.
CALL TRANSFORMATION xslt_person
SOURCE XML input_xml
RESULT all_people = lt_person.
CATCH cx_root.
WRITE 'Problemo!'.
ENDTRY.
WRITE 'Now, debug the program to see the values read from the XML'.
</PRE>
<HR>
and here is the XSLT Transformation program (xslt_person):
<HR>
<PRE>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ALL_PEOPLE>
<xsl:apply-templates select="//People"/>
</ALL_PEOPLE>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="People">
<ALLMYFRIENDS> <!This element name is not relevent... needed to just group the loop>
<FIRSTNAME>
<xsl:value-of select="FirstName"/>
</FIRSTNAME>
<SURNAME>
<xsl:value-of select="Surname"/>
</SURNAME>
<ADDRESSES>
<xsl:for-each select="Address">
<ADDRESS> <!This element name is not relevent... needed to just group the loop>
<HOUSE_NO>
<xsl:value-of select="HouseNo"/>
</HOUSE_NO>
<STREET_NAME>
<xsl:value-of select="Street"/>
</STREET_NAME>
<CITY_NAME>
<xsl:value-of select="City"/>
</CITY_NAME>
<PHONE_NO>
<xsl:value-of select="PhoneNo"/>
</PHONE_NO>
</ADDRESS>
</xsl:for-each>
</ADDRESSES>
</ALLMYFRIENDS>
</xsl:template>
</xsl:transform>
</PRE>
<HR>
HTH,
Jayanta.thanks a LOT Jayanta..
I was looking for an XSLT example for some time.. this one atleast got me started in the right direction..
THANKS -
XSLT-transformation in Java-Mapping with javax.xml
Hi,
we wanna use javax.xml for transformations in Java-Mapping.
Inside the Java-mapping we read in XSL-files to transform a XML-stream. With XSLT 1.0 everything works fine - but with XSLT 2.0 we are getting runtime errors.
Is it possible that javax.xml only supports XSLT 1.0?
Regards
WolfgangHi ,
Jaxp 1.3 is available in this link -
http://java.sun.com/webservices/jaxp/
Use these jar files to process XSLT 2.0.
Nanda -
XSLT Transformation ABAP to XML speacial treatment of empty elements
Dear All,
I have created a deep abap structure which basically reflects the structure of my XML file which I would like to generate later. I have created a transformation via transaction SE80->create XSLT Program. I am also using the ABAP command call transformation...
I have made a few ammendments to my XSLT program where required.
I am outputting data in a loop.
But I got a problem with one field. I must check if this date field is initial.
Which I did by using statement:
<xsl:if test="ENDDATE='0000-00-00'">
But if this field is initial I have to output the following tag:
<ENDDATE ReasonForNull="9"></ENDDATE>
Hence I defined an attribute below in my element as follows:
<xsl:for-each select="INSTANCE/_-PIQGB_-INSTANCE_XML">
<xsl:if test="ENDDATE='0000-00-00'">
<xsl:element name="ENDDATE">
<xsl:attribute name="ReasonForNull"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
Which generates now the output as follows and is quitwe close to the desired output:
<ENDDATE ReasonForNull=""></ENDDATE>
Can anybody make a suggestion how I can generate the desired output.
I assume that I would have to assign a value to the attribute to get the right output. But I got no idea how I could this in the loop.
Many thanks in advance.
RainerHello Rainer
The solution is quite simple. See the example below.
" Sample XML file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../tmp_EDI_ZZ_tests/Untitled2.xsl"?>
<INVOIC02>
<INSTANCE>
<ENDDATE>2008-07-31</ENDDATE>
</INSTANCE>
<INSTANCE>
<ENDDATE>0000-00-00</ENDDATE>
</INSTANCE>
</INVOIC02>
" Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="ISO-8859-1" method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:for-each select="INSTANCE">
<xsl:choose>
<xsl:when test="ENDDATE='0000-00-00' ">
<xsl:element name="ENDDATE">
<xsl:attribute name="ReasonForNull">
<xsl:value-of select=" '9' "/> " Set value for attribute !!!
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
" Result of transformation:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ENDDATE>2008-07-31</ENDDATE>
<ENDDATE ReasonForNull="9"/>
Regards
Uwe -
I need help writing and XSLT to transform an XML in InDesign. I am new to XML and have no idea how to write an XSLT.
We are trying to bring in data from a database using a query language that is having trouble creating the image tags the way we need it to. Basically, I need to take this:
<Project href="file://C:\My test phot.jpg">
and transform it into this:
<Project> <image href="file://C:\My test phot.jpg" />
Can anyone help me with this?
Thanks!Not sure I can help you with this, as my understanding of XSL is very limited.
However, as a matter of trial and error, I find that if I transform this XML:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Project href="file://C:\My test phot1.jpg">The first bit of textual content here</Project>
<Project href="file://C:\My test phot2.jpg">The second bit of textual content here</Project>
<Project href="file://C:\My test phot3.jpg">The third bit of textual content here</Project>
<Project href="file://C:\My test phot4.jpg">The fourth bit of textual content here</Project>
<Project href="file://C:\My test phot5.jpg">The fifth bit of textual content here</Project>
</Root>
...with this XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Root>
<xsl:for-each select="/Root/Project">
<Project>
<image><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute></image>
<xsl:value-of select="."/>
</Project>
</xsl:for-each>
</Root>
</xsl:template>
</xsl:stylesheet>
...I end up with this XML:
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<Project><image href="file://C:\My test phot1.jpg"/>The first bit of textual content here</Project>
<Project><image href="file://C:\My test phot2.jpg"/>The second bit of textual content here</Project>
<Project><image href="file://C:\My test phot3.jpg"/>The third bit of textual content here</Project>
<Project><image href="file://C:\My test phot4.jpg"/>The fourth bit of textual content here</Project>
<Project><image href="file://C:\My test phot5.jpg"/>The fifth bit of textual content here</Project>
</Root>
...which seems what you're looking for.
[I edited the original solution slightly by removing a wildcard.] -
Default XSLT Stylesheet to transform BW XML Data?
I'm currently working on a deafult XSLT Stylesheet to convert a BW XML Query Result Set into an html grid.
[code]
<!--
#==========================================================================
XSL Transformation that displays
Template Properties, List of Data Providers and List of Items
#==========================================================================
-->
<xml id="xsl_transform_1">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="header">
<tr bgcolor="white"> <xsl:for-each select="//RRWS_SX_TUPLE[1]/*">
<td>
<xsl:value-of select="local-name()"/>
</td>
</xsl:for-each>
</tr>
</xsl:variable>
<xsl:template match="/">
<table bgcolor="gold" border="1">
TESTVALUE -
<tr>
<xsl:copy-of select="$header" /> <xsl:apply-templates />
</tr>
<xsl:for-each select="//RRWS_SX_TUPLE">
<tr>
<td><xsl:value-of select="TUPLE_ORDINAL"/></td>
<xsl:for-each select="//RRWS_S_CELL">
<td><xsl:value-of select="CELL_ORDINAL"></td>
</xsl:for-each>
<td><xsl:value-of select="TUPLE_ORDINAL"/></td>
<td><xsl:value-of select="CHANM"/></td>
<td><xsl:value-of select="CAPTION"/></td>
<td><xsl:value-of select="CHAVL"/></td>
<td><xsl:value-of select="CHAVL_EXT"/></td>
<td><xsl:value-of select="NIOBJNM"/></td>
<td><xsl:value-of select="TLEVEL"/></td>
<td><xsl:value-of select="DRILLSTATE"/></td>
<td><xsl:value-of select="OPT"/></td>
<td><xsl:value-of select="SIGN"/></td>
<td><xsl:value-of select="ATTRIBUTES"/></td>
</tr>
<xsl:for-each select="//RRWS_S_CELL">
<tr>
<td><xsl:value-of select="CELL_ORDINAL"/></td>
<td><xsl:value-of select="VALUE"/></td>
<td><xsl:value-of select="FORMATTED_VALUE"/></td>
<td><xsl:value-of select="VALUE_TYPE"/></td>
<td><xsl:value-of select="CURRENCY"/></td>
<td><xsl:value-of select="UNIT"/></td>
<td><xsl:value-of select="MWKZ"/></td>
<td><xsl:value-of select="NUM_SCALE"/></td>
<td><xsl:value-of select="NUM_PREC"/></td>
<td><xsl:value-of select="CELL_STATUS"/></td>
<td><xsl:value-of select="BACK_COLOR"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="RRWS_S_CELL/*">
<td> <xsl:value-of select="." /> </td>
</xsl:template></xsl:stylesheet>
</xml>
[/code]
I've started this, but I need to join the top tree with the bottom. Right now I'm just flattening the tree. Does anyone know if any work has been done in this area? I'm looking to create these XSLT Transforms. Also, I'd like to create generic javascript functions that I can use as an include, such as
function join_BW_Table(table1, table2, fieldtojoin, typeofjoin)
This would allow anyone to generically combine BW Data from multiple sources all on the FrontEnd and render it all as an html table. My ultimate goal would be have all this in includes and available for all BW Reporting. Anyone have any thoughts on:
1. Has this been done before?
2. If it hasn't, anyone have comments on how I can combine the 2 tables that I'm rendering with the attached XSLT transform?
I'm running these transforms via a javscript function on the load of the html page.
PrakashPrakash,
did you ever compile the Stylesheet? I am looking for an alternative way to format the pre-compiled XML file from the Report Designer. The more complex my report is, the less robust the application becomes.
Your insight would be greatly appreciated.
Thank you -
How to use OAF transform sotred xml documents using XSLT...
Does anyone have any experience using XSLT in OAF? Specifically, I have xml documents stored in a clob to which I wish to apply an XSLT transformation and then store the transformed documents back into the clob. Is there a way to apply an XSLT transformation using say BI-Publisher via OAF?
"XML DIFF" are the keywords you can use to search for products that do this. Last time I looked there was a lot of XML Diff implementations, but none of them produced human-readable output that I really liked. I expect that's because XML diff is an easy thing for people to ask for but not an easy thing to do, given the considerable number of ways there are to change a document.
Maybe you are looking for
-
ITUNES COPY AND PASTE ARTWORK PROBLEM
Ive had a problem ever since I downloaded the newest itunes update and want to see if anyone else is having this issue. I hope I can explain this accurately. When you have the album artwork displayed on the bottom left hand of the itunes screen. I
-
Want to see ALL issues and risks, not just mine. Is this possible?
I'm relatively new to Project Online, but I have four projects in it with associated risks and issues. It looks like I can only see risks and issues that are assigned to me, which is fine for now, but as these projects get further down the line (or
-
HELP! I really need to get my pictures back! I can't belive it ;(;(;(;(;(
-
Installation woes with 2008-04-RC & 2008-03
Well, here goes. Firstly, I installed 2007-08. I assumed this was the most recent, as it was on the main page and all. Install went fine except for the network card, which I eventually fixed by grabbing new drivers (r8168). I tried to install some
-
How to set Borderlayout?
Hi all, I used BorderLayout in JPanel. I have added JTextArea at CENTER and JList at EAST. Jpanel is in JFrame. The size of JList is depend on Element that longest but when I remove all element and try to resize JFrame, the JList which has no element