Concatenate nested XML tags
Hello,
I'm looking for a solution to concatenate duplicate tags in a xml.
I need only the tags 'tag' of 'type=keyword' in one field in a table.
The sql statement I use I'm getting six records and I just need one record.
Hope my English writing is not to bad to understand what I mean.
This is a part of the XML.
<?xml version='1.0' encoding='UTF-8'?>
<list>
<artikel id='25230245' title='st' publish='true' sender=''>
<categorieen>
<categorie naam='Staking' externalid='Economie/Staking' />
</categorieen>
<geoinfo latitude='52.3936' longitude='6.142065' zoom='15' />
<tags>
<tag name='Overijssel/Raalte/Raalte' type='location' />
<tag name='Overijssel/Deventer/Deventer' type='location' />
<tag name='Overijssel/Olst-Wijhe/Wijhe' type='location' />
<tag name='cao' type='keyword' />
<tag name='vleeswarensector' type='keyword' />
<tag name='seniorenregeling' type='keyword' />
<tag name='fnv bondgenoten' type='keyword' />
<tag name='werkonderbreking' type='keyword' />
<tag name='Zwanenburg' type='keyword' />
<tag name='staking' type='keyword' />
<tag name='Stegeman' type='keyword' />
<tag name='Lüpack' type='keyword' />
<tag name='cnv vakmensen' type='keyword' />
</tags>
<publicatiedatum datum='1400663902374' datumstr='2014-05-21T11:18:00+0200' />
<wijzigingsdatum datum='1400663902374' datumstr='2014-05-21T11:18:00+0200' />
<printdatum datumstr='22-05-2014' />
<bestemmingen>
<bestemming channel='web' site='ST' page='Regio/Deventer/' primary='false' />
<bestemming channel='web' site='ST' page='Regio/Olst-Wijhe/' primary='false' />
<bestemming channel='web' site='ST' page='Regio/Raalte/' primary='true' />
</bestemmingen>
<bron naam='Benny Koerhuis' />
<beelden />
</artikel>
</list>
And this is my sql statement (part of a plsql procedure).
SELECT decode(upper(t1.publish), 'TRUE', 'Y', 'N')
, trunc(to_date(substr(replace(t1.pdate, 'T', ' '), 1, 19), 'YYYY-MM-DD HH24:MI:SS')) pdate
, to_date(substr(replace(t1.flitstijd, 'T', ' '), 1, 19), 'YYYY-MM-DD HH24:MI:SS') flitstijd
, t1.naam_flitser
, t1.sectie
, t1.titel
, t1.soort
, t2.trefwoorden
FROM flits_berichten_clob t1
, XMLTABLE('//test/artikel'
PASSING XMLTYPE (t1.xml_file)
COLUMNS publish VARCHAR2(10) PATH '@publish'
,pdate VARCHAR2(25) PATH 'publicatiedatum/@datumstr'
,flitstijd VARCHAR2(25) PATH 'wijzigingsdatum/@datumstr'
,naam_flitser VARCHAR2(25) PATH 'bron/@naam'
,sectie VARCHAR2(255) PATH 'bestemmingen/bestemming[@primary="true"]/@page'
,titel VARCHAR2(10) PATH 'bestemmingen/bestemming[@primary="true"]/@site'
,soort VARCHAR2(10) PATH 'bestemmingen/bestemming[@primary="true"]/@channel'
,tags XMLTYPE PATH 'tags') t1
, XMLTABLE('/tags/tag[@type="keyword"]'
PASSING t1.tags
COLUMNS trefwoorden VARCHAR2(255) PATH '@name') t2
WHERE id = 15;
This is the result.
Y
21-05-2014
21-05-2014 11:18:00
Benny Koerhuis
Regio/Raalte/
ST
web
werkonderbreking
Y
21-05-2014
21-05-2014 11:18:00
Benny Koerhuis
Regio/Raalte/
ST
web
Zwanenburg
Y
21-05-2014
21-05-2014 11:18:00
Benny Koerhuis
Regio/Raalte/
ST
web
staking
Y
21-05-2014
21-05-2014 11:18:00
Benny Koerhuis
Regio/Raalte/
ST
web
Stegeman
Y
21-05-2014
21-05-2014 11:18:00
Benny Koerhuis
Regio/Raalte/
ST
web
Lüpack
Y
21-05-2014
21-05-2014 11:18:00
Benny Koerhuis
Regio/Raalte/
ST
web
cnv vakmensen
Is there a way to concatenate the results from the last column?
It result should be 'werkonderbreking, Zwanenburg, staking, Stegeman, Lüpack, cnv vakmensen' so I get one record instead of six.
Thanks in advance.
Is there a way to concatenate the results from the last column?
Yes, use string-join function :
, titel
VARCHAR2(10) PATH 'bestemmingen/bestemming[@primary="true"]/@site'
, soort
VARCHAR2(10) PATH 'bestemmingen/bestemming[@primary="true"]/@channel'
, trefwoorden
VARCHAR2(4000) PATH 'string-join(tags/tag[@type="keyword"]/@name, ",")'
) t1
That way you don't need the second XMLTABLE anymore.
Similar Messages
-
How to create nested xml tags using java parser?
Hi,
I need to create a xml file containing following tags using java program-
<A attr1="abc">
<B attr2="xyz">
<C attr3="pqr"> </C>
</B>
</A>
Can anyone please let me know which parser should I use to create the above mentioned xml file?
If possible, please post a code snippet for the same.
Thanks in advance..Well, you could start by doing it all the 'old fashioned' way; create a String object containing that text and then write it away to a file. Or you could take the time to look at the javadoc for all of the xml support that the Java language itself supplies - XMLReader/Writer for a start. After that put together some code that you think would do the job and ask for help on any specific problems you encounter.
-
XML tags in an "export : XML" Report Template
Hi All,
I'm using the export XML report template to produce XML from a query. One of the column contains XML tags and the template is translating eg: if the column is "Groups" then I get:
<Groups>& lt ;Group& gt ;Sales & lt ;/Group & gt ; & lt ;Group& gt ;IT& lt ;/Group& gt ;</Groups>(ignoring all the spaces - OTN is translating the & gt 's :)
instead of:
<Groups><Group>Sales<Group><Group>IT</Group></Groups>Is there an easy way to stop this ?
Thanks,
Steve
Edited by: spilgrim on Mar 6, 2009 12:14 PM
Edited by: spilgrim on Mar 6, 2009 12:14 PMHi Steve,
Did you ever solve this? I'm having a similar issue while trying to build a Report Query that I want to build with nested elements.
<?xml version="1.0" encoding="UTF-8" ?>
- <ROWSET>
- <ROW>
<EE_ID>467</EE_ID>
<EE_GRIDS>
<EE_GRID INDEX="1">
<EE_INCENTIVE_CASH_PROGRAM>MIP</EE_INCENTIVE_CASH_PROGRAM>
<EE_BONUS>20</EE_BONUS>
</EE_GRID>
<EE_GRID INDEX="2">
<EE_INCENTIVE_CASH_PROGRAM>VIP</EE_INCENTIVE_CASH_PROGRAM>
<EE_BONUS>30</EE_BONUS>
</EE_GRID>
</EE_GRIDS>
</ROW>
- <ROW>
<EE_ID>468</EE_ID>
<EE_GRIDS>
<EE_GRID INDEX="1">
<EE_INCENTIVE_CASH_PROGRAM>MIP</EE_INCENTIVE_CASH_PROGRAM>
<EE_BONUS>20</EE_BONUS>
</EE_GRID>
<EE_GRID INDEX="2">
<EE_INCENTIVE_CASH_PROGRAM>VIP</EE_INCENTIVE_CASH_PROGRAM>
<EE_BONUS>30</EE_BONUS>
</EE_GRID>
</EE_GRIDS>
</ROW>
</ROWSET>
Thanks
Keith
Edited by: kmatthew on Mar 17, 2009 2:44 PM -
Replace the XML Tags which are in binary format in 4.6C Version
Hi Experts,
I have an issue. I am working on 4.6 c version of sap. I have a requirement to send ftp of an xml file. I created an internal table which has components of table type too ( For Line items ). After appending a record of sales order into the table I am using SDIXML_DATA_TO_DOM ( To attach the to the document ) and SDIXML_DOM_TO_XML ( To convert the document contents into XML ( Binary Format ).
CLASS cl_ixml DEFINITION LOAD.
g_ixml = cl_ixml=>create( ).
CHECK NOT g_ixml IS INITIAL.
m_document = g_ixml->create_document( ).
CHECK NOT m_document IS INITIAL.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'xmldata' " data in character format
DATAOBJECT = xmldata[]
IMPORTING
DATA_AS_DOM = l_dom
CHANGING
DOCUMENT = m_document
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CHECK NOT l_dom IS INITIAL.
w_rc = m_document->append_child( new_child = l_dom ).
IF w_rc IS INITIAL.
WRITE 'OK'.
ELSE.
WRITE: 'ERR ='.
ENDIF.
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = m_document
PRETTY_PRINT = ' '
IMPORTING
XML_AS_STRING = w_string
SIZE = w_size
TABLES
XML_AS_TABLE = it_xml " Final XML data ( with xml tags ( xml tags are the field names of internal table ) ) in bin
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2
IF SY-SUBRC = 0.
WRITE 'OK'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
WRITE: 'ERR =',
sy-subrc.
ENDIF.
So, it_xml has the binary format of XML data.
Now the requirement is that I need to get rid of some XML tags in the final internal table XML data. Because by default, at the start of the the table row the <item> and </item> tags are inserted. This is automatically done in the Function module
SDIXML_DOM_TO_XML.
I want to find out the binary string of <item> and </item> and replace them by null binary string. I know how to replace the character strings but not for binary strings in 4.6 C.
It is little bit urget. I would appreciate the quicker answer.Hi,
check this program , I think this will help you
TYPE-POOLS: ixml.
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
data : itab like catsdb occurs 100 with header line.
data : file_location type STRING.
data : file_name like sy-datum.
data : file_create type STRING.
file_name = sy-datum .
file_location = 'C:\xml\'.
concatenate file_location file_name into file_create.
concatenate file_create '.XML' into file_create.
DATA: l_xml_table TYPE TABLE OF xml_line,
l_xml_size TYPE i,
l_rc TYPE i.
select * from catsdb into table itab.
append itab .
CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
I_XML_DOC_NAME =
IMPORTING
PE_BIN_FILESIZE = l_xml_size
TABLES
i_tab_sap_data = itab
CHANGING
I_TAB_CONVERTED_DATA = l_xml_table
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 24
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = file_create
filetype = 'BIN'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
write : 'INTERNAL TABLE DATA IS SUCCESSFULLY DOWNLOADED TO LOCATION', file_create .
Thanks. -
How to read duplicate XML tag?
Hi to all gurus,
Currently I am working on XSLT transformation. I encountered a problem when I have to read a random number of xml tag with the same names.
sample:
<product_code_list>
<product_code>12345</product_code>
<product_code>12333</product_code>
<product_code>12233</product_code>
</product_code_list>
My xslt can only manage to read the 1st row. How can it be possible to read all the 3 rows?
xslt:
<product_code_list>
<xsl:for each select-value-of='product_code_list'>
<product_code_list1>
<product_code><xsl: select-value-of ='product_code'></product_code>
</product_code_list1>
</xsl:for each>
</product_code_list>
Many thanks in advance for reading this. Please assist to solve this. Point will be generously awarded!Hi Mr Raja!
Thanks again for your help. I felt so embarrassed.
The product is produced from another source dynamically. Hence the list can contain from 1 to any number of products.
I tried to use the for-each but another problem arise. the structure is created for the products, but it is all empty inside when i used the debugger to go through the code.
TYPES:
TPRODUCT(10) OCCURS 0,
BEGIN OF PRODUCT_LIST,
PRODUCT TYPE TPRODUCT,
END OF PRODUCT_LIST,
PL TYPE PRODUCT_LIST OCCURS 0.
DATA:
VENDOR TYPE STANDARD TABLE OF PRODUCT_LIST INITIAL SIZE 0,
XML_STRING TYPE STRING,
xslt_error TYPE REF TO cx_xslt_exception,
xslt_message TYPE string.
CLEAR xml_string .
CONCATENATE
`<myXML>`
`<PRODUCT_LIST>`
`<PRODUCT>12345</PRODUCT>`
`<PRODUCT>12333</PRODUCT>`
`<PRODUCT>62233</PRODUCT>`
`</PRODUCT_LIST>`
`</myXML>`
INTO XML_STRING.
CLEAR VENDOR.
TRY.
CALL TRANSFORMATION ('ZTESTCHINXSLT')
SOURCE XML XML_STRING
RESULT VENDOR = VENDOR.
CATCH
cx_xslt_exception INTO xslt_error.
xslt_message = xslt_error->get_text( ).
ENDTRY.
XSLT:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/abapxml" version="1.0">
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml">
<asx:values>
<xsl:for-each select="myXML">
<VENDOR>
<xsl:for-each select="PRODUCT_LIST">
<PRODUCT_LIST1>
<PRODUCT>
<xsl:for-each select="PRODUCT">
<P>
<xsl:value-of select="PRODUCT"/>
</P>
</xsl:for-each>
</PRODUCT>
</PRODUCT_LIST1>
</xsl:for-each>
</VENDOR>
</xsl:for-each>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
Message was edited by:
swee chin -
Nested XML Output in PL/SQL
I need to generate XML that looks like this:
<Person>
<Name>
<FirstName>IMA</FirstName>
<MiddleName>ANOTHER</MiddleName>
<LastName>TEST</LastName>
<BirthDate>04/05/1982</BirthDate>
</Name>
<IDDetails>
<SSNID>234-23-3333</SSNID>
<OtherID>19781</OtherID>
</IDDetails>
<PhysicalDetails>
<Weight>145</Weight>
<EyeColor>BLUE</EyeColor>
<HairColor></HairColor>
<Sex>FEMALE</Sex>
<Race>BLACK</Race>
<SkinToneText></SkinTone>
</PhysicalDetails>
<SocialDetails>
<Ethnicity>UNKNOWN</Ethnicity>
<Language>ENGLISH</Language>
</SocialDetails>
<Address>
<Street>123 Somewhere Street</Street>
<City>AnyWhere</City>
<State>Confusion</State>
<Zip>99999</Zip>
</Address>
</Person>
I was able to sucessfully generate it in SQL by creating a view using this code:
create or replace view person_xml_view as
select
xmlelement("Person",
xmlelement("Name",
xmlelement("FirstName", first_name),
xmlelement("MiddleName",middle_name),
xmlelement("LastName",last_name),
xmlelement("BirthDate",to_char(date_of_birth,''MM/DD/YYYY''))),
xmlelement("IDDetails",
xmlelement("SSN",b.external_number),
xmlelement("OtherID",a.mni)),
xmlelement("PhysicalDetails",
xmlelement("Weight",a.weight),
xmlelement("EyeColor",a.eye_color),
xmlelement("HairColor",a.hair_color),
xmlelement("Sex",a.sex),
xmlelement("Race",a.race),
xmlelement("SkinTone",a.skin_tone)),
xmlelement("SocialDetails",
xmlelement("Ethnicity",ethnicity),
xmlelement("Language",language)),
xmlelement("Address",
xmlelement("Street",c.address),
xmlelement("City",c.city),
xmlelement("State",c.state),
xmlelement("Zip",c.zip)))
as result from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = 'SOCIAL SECURITY NUMBER') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= 'T') AND
a.MNI = 19781);
My end goal is to write a function that returns the XML back to the caller, but when I the dbms_xmlgen I can't get the sub-tags to be inserted correctly. Here's the code as it is today:
FUNCTION GETXML
( v_pk IN Number)
RETURN xmltype as out xmltype;
ctx dbms_xmlgen.ctxhandle;
BEGIN
ctx := dbms_xmlgen.newcontext('select a.first_name as "FirstName",
a.middle_name as "MiddleName",
a.last_name as "LastName",
to_char(a.date_of_birth,''MM/DD/YYYY'') AS "BirthDate",
b.external_number as "SSNID",
a.mni as "OtherID",
a.weight as "Weight",
a.eye_color as "EyeColor",
a.hair_color as "HairColor",
a.sex as "Sex",
a.race as "Race",
a.skin_tone as "SkinTone",
a.ethnicity as "Ethnicity",
a.language as "Language",
c.address as "Street",
c.city as "City",
c.state as "State",
c.zip as "Zip"
from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = ''SOCIAL SECURITY NUMBER'') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= ''T'') AND
a.MNI = '||V_MNI);
dbms_xmlgen.setrowsettag(ctx,'Person');
dbms_xmlgen.setrowtag(ctx,'Name');
dbms_xmlgen.setrowtag(ctx,'IDDetails');
dbms_xmlgen.setrowtag(ctx,'PhysicalDetails');
dbms_xmlgen.setrowtag(ctx,'SocialDetails');
dbms_xmlgen.setrowtag(ctx,'Address');
out := dbms_xmlgen.getxmltype(ctx);
dbms_xmlgen.closecontext(ctx);
return out;
END;
How do you do the nested tags?Hi,
Here is simple way of genrating nested XML.
FUNCTION GETXML
( v_pk IN Number)
RETURN sys.XMLType
CURSOR C1
IS
xmlelement("Person",
xmlelement("Name",
xmlforest(first_name as "FirstName",
middle_name as "MiddleName",
last_name as "LastName",
to_char(date_of_birth,''MM/DD/YYYY'') as"BirthDate"),
xmlelement("IDDetails",
xmlforest(b.external_number as "SSN",
a.mni as "OtherID")),
xmlelement("PhysicalDetails",
xmlforest(a.weight as "Weight",
a.eye_color as "EyeColor",
a.hair_color as "HairColor",
a.sex as "Sex",
a.race as "Race",
a.skin_tone as "SkinTone")),
xmlelement("SocialDetails",
xmlforest(ethnicity as "Ethnicity",
language as "Language")),
xmlelement("Address",
xmlforest(c.address as "Street",
c.city as "City",
c.state as "State",
c.zip as "Zip")) as result
from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = 'SOCIAL SECURITY NUMBER') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= 'T') AND
a.MNI = 19781);
v_xml sys.XMLType
BEGIN
open c1;
fetch c1 into v_xml;
close c1;
return v_xml;
END
In short use xmlforest to genrate inner child tags. -
Dynamic XML TAGS in PL/SQL
Hi I wish to have dynamic xml tags in pl/sql e.g. say i have a table xml_table with xml_tag and tag_value as two columns. Let us say it has a rows
XML_TAG = timezone
TAG_VALUE = UK
I want the output in the following format
<timezone>UK</timezone>.
Any ideas how to achieve it using ORACLE functions and not concatenate <> to the columns? Help would be much appreciated.This is a forum discussing questions related to Oracle Portal. I'd recommend you to take a look at XDB and XSQL, on Oracle's Web site at http://otn.oracle.com.
Hope it helps,
Peter -
Hi there,
I have a problem with displaying some nested XML data. I've
tried quite a lot of different approachey to this, but just can't
get it working properly. So here's the deal:
I have an XML file (which is dynamically created from a
servlet) of the form:
<variations>
<variation>
<name>...</name>
<...>...</...>
<links>
<link>
<type>...</type>
<name>...</name>
</link>
</links>
</variation>
</variations>
On my webpage, I use a Spry tabbed panel with one tab for
each of the 'variation's in the XML file. Within the tabs I have
(many) form fields dynamically filled with the values from the XML
and that all works fine, but I also want to display a table with
one row corresponding to each 'link'... and that just won't work...
My latest approach looks something like this:
<head>
<script type="text/javascript">
<!--
var dsVariations = new
Spry.Data.XMLDataSet("Servlet?id=1&cmd=getVariations",
"variations/variation");
var dsLinks = new
Spry.Data.XMLDataSet("Servlet?id=0&cmd=getLinks",
"links/link");
//-->
</script>
</head>
<body>
<div id="TabbedPanels1" spry:region="dsVariations">
<div id="TP1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<li spry:repeat="dsVariations" class="TabbedPanelsTab"
tabindex="0">{dsVariations::name}</li>
</ul>
<div class="TabbedPanelsContentGroup">
<div spry:repeat="dsVariations"
class="TabbedPanelsContent">
// a lot of form stuff
<table border="1">
<script type="text/javascript">
dsLinks.setURL("Servlet?id={dsVariations::id}&cmd=getLinks");
dsLinks.loadData();
</script>
<tr spry:repeat="dsLinks">
<td>{dsLinks::type}</td>
<td>{dsLinks::name}</td>
</tr>
</tr>
</table>
</div>
</div>
</body>
In this, the Servlet call with cmd=getVariations returns the
whole XML stated above, while the cmd=getLinks will only get the
corresponding part (everything between <links> and
</links>).
The error message I get for this is: processTokens() failed
to get a data set context!.
I previously tried to use a NestedXMLDataSet, but couldn't
get that working either... I'm really kind of stuck by now and
would appreciate any help.
Thanks,
Florian
PS Thanks a lot for creating Spry: It's great!Thanks for your reply, Cristian.
I'm afraid I couldn't do that since it would cause the whole
region to be reloaded constantly (because it's being updated each
time I do the setURL / loadData)... in fact, I tried this before
and it didn't work.
But, in fact, I figured that the fact that I could not get it
running using a NestedXMLDataSet (as I would generally prefer), did
not actually come down to a problem in the page source code, but
actually to a problem with the very XML itself:
I tried to recreate the simple nested data set example (
http://labs.adobe.com/technologies/spry/samples/data_region/NestedDataSample.html)
and basically used the same code and an almost identical XML
structure... yet it doesn't work. The contents of dsFeatures just
won't be displayed and when I'm inspecting the contents of
dsFeatures (using Firebug) it shows me that the dataset is empty. I
just don't get why it works for your example, but not for my
modified version... I can't see any crucial difference :-s.
To simplify the problem I deleted most tags from the XML and
saved it in a static document "variations.xml":
<variations>
<variation>
<name>Var 1</name>
<features>
<feature>none</feature>
<feature>feat1</feature>
<feature>feat2</feature>
</features>
</variation>
<variation>
<name>Var 2</name>
<features>
<feature>none</feature>
</features>
</variation>
</variations>
The source of the test page would be:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml"
xmlns:spry="
http://ns.adobe.com/spry">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Nested Data Sample</title>
<script language="JavaScript" type="text/javascript"
src="SpryAssets/xpath.js"></script>
<script language="JavaScript" type="text/javascript"
src="SpryAssets/SpryData.js"></script>
<script language="JavaScript" type="text/javascript"
src="SpryAssets/SpryNestedXMLDataSet.js"></script>
<script type="text/javascript">
var dsVariations = new Spry.Data.XMLDataSet("variations.xml",
"/variations/variation");
var dsFeatures = new Spry.Data.NestedXMLDataSet(dsVariations,
"features/feature");
</script>
</head>
<body>
<table border="1">
<tr>
<th width="30%"
onclick="dsVariations.sort('name');">dsVariations</th>
<th width="30%"
onclick="dsFeatures.sort('link')">dsFeatures</th>
<th width="30%">dsVariations + dsFeatures</th>
</tr>
<tr>
<td valign="top"><div
spry:region="dsVariations">
<ul>
<li spry:repeat="dsVariations" spry:select="select"
spry:hover="hover" spry:setrow="dsVariations"> {name}
</li>
</ul>
</div></td>
<td valign="top"><div spry:region="dsFeatures">
<ul>
<li spry:repeat="dsFeatures"> {dsFeatures::feature}
</li>
</ul>
</div></td>
<td valign="top"><div spry:region="dsVariations
dsFeatures">
<ul>
<li spry:repeat="dsVariations"> {dsVariations::name}
<ul>
<li
spry:repeat="dsFeatures">{dsFeatures::feature}</li>
</ul>
</li>
</ul>
</div></td>
</tr>
</table>
</body>
Evidently, I'm missing some essential simple point here...
Thanks, -
How do you use nested XML in InDesign such as DocBook upon import?
Something like:
<blockquote>
<para>Some text here</para>
<para>More text here</para>
</blockquote>
I know InDesign has the map tags to styles function... how could this sort of nesting be interpretted as styles though?
Would you map the blockquote element as [Not Mapped]... or as a character style? or what?
<para> Can't be a paragraph style since it is also used as the body text.
Would something like this have to be scripted to import correctly?There is not a good way to express concepts like <blockquote/> in InDesign's XML import.
I don't see anything here that is "nesting," though. Perhaps if you gave us the context?
If you have your other <para/>s in some other tag instead of <blockquote/> then they could all be paragraph styles. But if you have <para/>s at varying tree levels, you are really stuck. Transofrm it into some other kind of XML, or use scripting.
So, try giving us a lot more (5 times as much?) context and a clear explanation of what you want to do, but I think this is probably not a good approach. -
How to read entire file content in one XML tag?
Hi,
How can I read entire file content in one XML tag?
What specifications do I need to specify in Sender adapter?
regards,
Anirudh.Hi Chirag,
I am reading a flat file for File to Idoc scenario.
Target Idoc is nested which can not be populated with graphical mapping.
see below post for more detail.
[Mapping flat XML to nested IDOC using node functions |Mapping flat XML to nested IDOC using node functions;
The problem here is I'm not able to identify when to insert context change for child which is repeating for a repeating parent.
Solution therefore, I think is reading entire flat structure in one node and then use UDF to populated intermediate target with proper nesting.
Thats why I need to read entire XML.
regards,
Anirudh. -
Create xml tag dynamically within simple transformation
Hi all together,
I'm faceing the following problem:
There is a internal table provided, consisting of name/value-pairs. Something like
ls_struc-name = 'NAME1'.
ls_struc-value = 'XYZ'.
append ls_struc to lt_struc
ls_struc-name = 'CITY1'.
ls_struc-value = 'Munich'.
append ls_struc to lt_struc
and so on.
I have to create this XML (with simple transformation):
<NAME1>XYZ</NAME1>
<CITY1>Munich</CITY1>
Everythings works fine so far (tables, values etc.), but I have problems with creating the XML-Tag, e.g <NAME1> from "$line.name" within the transformation. I don't have any information about the data structure (therefore "call transaction id" does not work).
Any hint is useful!!!
Best regards,
ThomasExaple program for creating XML file from abap
REPORT z_xit_xml_dom_create.
TYPE-POOLS: ixml.
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_ostream TYPE REF TO if_ixml_ostream,
l_renderer TYPE REF TO if_ixml_renderer,
l_document TYPE REF TO if_ixml_document.
DATA: l_element_flights TYPE REF TO if_ixml_element,
l_element_airline TYPE REF TO if_ixml_element,
l_element_flight TYPE REF TO if_ixml_element,
l_element_from TYPE REF TO if_ixml_element,
l_element_to TYPE REF TO if_ixml_element,
l_element_dummy TYPE REF TO if_ixml_element,
l_value TYPE string.
DATA: l_xml_table TYPE TABLE OF xml_line,
l_xml_size TYPE i,
l_rc TYPE i.
DATA: lt_spfli TYPE TABLE OF spfli.
DATA: l_spfli TYPE spfli.
START-OF-SELECTION.
* Fill the internal table
SELECT * FROM spfli INTO TABLE lt_spfli.
* Sort internal table
SORT lt_spfli BY carrid.
* Start filling xml dom object from internal table
LOOP AT lt_spfli INTO l_spfli.
AT FIRST.
* Creating a ixml factory
l_ixml = cl_ixml=>create( ).
* Creating the dom object model
l_document = l_ixml->create_document( ).
* Fill root node with value flights
l_element_flights = l_document->create_simple_element(
name = 'flights'
parent = l_document ).
ENDAT.
AT NEW carrid.
* Create element 'airline' as child of 'flights'
l_element_airline = l_document->create_simple_element(
name = 'airline'
parent = l_element_flights ).
* Create attribute 'code' of node 'airline'
l_value = l_spfli-carrid.
l_rc = l_element_airline->set_attribute( name = 'code' value = l_value ).
* Create attribute 'name' of node 'airline'
SELECT SINGLE carrname FROM scarr INTO l_value WHERE carrid EQ l_spfli-carrid.
l_rc = l_element_airline->set_attribute( name = 'name' value = l_value ).
ENDAT.
AT NEW connid.
* Create element 'flight' as child of 'airline'
l_element_flight = l_document->create_simple_element(
name = 'flight'
parent = l_element_airline ).
* Create attribute 'number' of node 'flight'
l_value = l_spfli-connid.
l_rc = l_element_flight->set_attribute( name = 'number' value = l_value ).
ENDAT.
* Create element 'from' as child of 'flight'
CONCATENATE l_spfli-cityfrom ',' l_spfli-countryfr INTO l_value.
l_element_from = l_document->create_simple_element(
name = 'from'
value = l_value
parent = l_element_flight ).
* Create attribute 'airport' of node 'from'
l_value = l_spfli-airpfrom.
l_rc = l_element_from->set_attribute( name = 'airport' value = l_value ).
* Create element 'to' as child of 'flight'
CONCATENATE l_spfli-cityto ',' l_spfli-countryto INTO l_value.
l_element_to = l_document->create_simple_element(
name = 'to'
value = l_value
parent = l_element_flight ).
* Create attribute 'airport' of node 'from'
l_value = l_spfli-airpto.
l_rc = l_element_to->set_attribute( name = 'airport' value = l_value ).
* Create element 'departure' as child of 'flight'
l_value = l_spfli-deptime.
l_element_dummy = l_document->create_simple_element(
name = 'departure'
value = l_value
parent = l_element_flight ).
* Create element 'arrival' as child of 'flight'
l_value = l_spfli-arrtime.
l_element_dummy = l_document->create_simple_element(
name = 'arrival'
value = l_value
parent = l_element_flight ).
* Create element 'type' as child of 'flight'
CASE l_spfli-fltype.
WHEN 'X'.
l_value = 'Charter'.
WHEN OTHERS.
l_value = 'Scheduled'.
ENDCASE.
l_element_dummy = l_document->create_simple_element(
name = 'type'
value = l_value
parent = l_element_flight ).
ENDLOOP.
IF sy-subrc NE 0.
MESSAGE 'No data into db table ''spfli'', please run program ''SAPBC_DATA_GENERATOR'' with transaction ''SA38''' TYPE 'E'.
ENDIF.
* Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
* Connect internal XML table to stream factory
l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
* Rendering the document
l_renderer = l_ixml->create_renderer( ostream = l_ostream
document = l_document ).
l_rc = l_renderer->render( ).
* Saving the XML document
l_xml_size = l_ostream->get_num_written_raw( ).
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = 'c:\temp\flights.xml'
filetype = 'BIN'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. -
Oracle code+simple XML tags
Hi ,
I wrote a shell script which contains " Oracle SQL query + simple XML tags".
the code was executing successfully.But My problem is to create a document based on the code.Don't mind any one please help me to preparingn the document..
Can I post the code here?? Is it right place to post my code.? Because I am new member to this forum..Please let me know...
I'll post the code as per ur suggestion..
Thank you..dbuser=SCOTT/TIGER
dbname=PRODDB
connect_string=$dbuser@$dbname
tableowner="DEVPS"
TABLEOWNER=$(echo $tableowner | tr '[a-z]' '[A-Z]')
#. ${MMHOME}/rfx/etc/config.env
OUT_DIR=/ifiles/inbox/data
# Set it to number of CPU on the server
MAX_THREAD=12
TASK_RUNNING=0
PROGRAM_NAME='Out_Source'
get_partname()
sqlplus -s $connect_string <<!
set pages 0
set feedback off
set heading off
SELECT PARTITION_NAME, PARTITION_POSITION
FROM DBA_TAB_PARTITIONS
WHERE TABLE_NAME='EMP'
ORDER BY PARTITION_POSITION;
exit;
create_part_flow()
cat > dats/outFlow_${PROGRAM_NAME}_$1.xml - <<EOF1
export PROGRAM_NAME="item_sale_$1"
. \${MMHOME}/config.env
. \${LIB_DIR}/lib.ksh
message "Program started ..."
\${ITEM_EXE} \${ITEM_OPTIONS} << EOF
<FLOW name="output.flow">
\${DBREAD}
<PROPERTY name="query">
<![CDATA[
SELECT <stmt>
]]>
</PROPERTY>
<OPERATOR type="convert">
<PROPERTY name="convertspec">
<![CDATA[
<CONVERTSPECS>
<CONVERT destfield="EMP_SAL" sourcefield="EMP_SAL" newtype="int16">
<CONVERTFUNCTION name="int16_from_dfloat"/>
<TYPEPROPERTY name="nullable" value="false"/>
</CONVERT>
</CONVERTSPECS>
]]>
</PROPERTY>
<OUTPUT name="tmp.v"/>
</OPERATOR>
</OPERATOR>
<OPERATOR type="export">
<INPUT name="tmp.v"/>
<PROPERTY name="outputfile" value="\${DATA_DIR}/sao0_irt_i_$1.dat"/>
<PROPERTY name="schemafile" value="\${SCHEMA_DIR}/item_on_off.schema"/>
</OPERATOR>
</FLOW>
EOF
checkerror -e $? -m "Program failed - check \${ERR_FILE}"
# Remove the status file
if [[ -f \${STATUS_FILE} ]]; then rm \${STATUS_FILE}; fi
message "Program completed successfully"
# cleanup and exit
rmse_terminate 0
EOF1
create_nopart_flow()
cat > outFlow_${PROGRAM_NAME}.xml - <<EOF
<FLOW name="output.flow">
<OPERATOR type="oraread">
<PROPERTY name="query">
<![CDATA[
<![CDATA[
SELECT <STmt>
]]>
</PROPERTY>
<OUTPUT name="tmp.v"/>
</OPERATOR>
<OPERATOR type="export">
<INPUT name="tmp.v"/>
<PROPERTY name="outputfile" value="sao0_irt_i_$1.dat"/>
</OPERATOR>
</FLOW>
EOF
create_full_flow()
cat > dats/item_sale.xml << EOF1
export PROGRAM_NAME="item_sale"
. \${MMHOME}/config.env
. \${LIB_DIR}/lib.ksh
ON_SALE_OUTPUT_FILE=\${DATA_DIR}/smo0_onseffdt_.txt
ON_SALE_OUTPUT_SCHEMA=\${SCHEMA_DIR}/item_on_sale.schema
OFF_SALE_OUTPUT_FILE=\${DATA_DIR}/sm0_ofseffdt_.txt
OFF_SALE_OUTPUT_SCHEMA=\${SCHEMA_DIR}/item_off_sale.schema
#export RFX_DEBUG=1
# input files:
ONOFF_DATE=\${DATA_DIR}/dm0_onseffdt_ofseffdt.dat
ONOFF_DATE_SCHEMA=\${SCHEMA_DIR}/item_on_off.schema
message "Program started ..."
\${RETL_EXE} \${RETL_OPTIONS} << EOF
<FLOW name="Store_Source.flw">
<OPERATOR type="import">
<PROPERTY name="inputfile" value="\${ONOFF_DATE}"/>
<PROPERTY name="schemafile" value="\${ONOFF_DATE_SCHEMA}"/>
<OPERATOR type="copy">
<OUTPUT name="on_off_sale.v"/>
</OPERATOR>
</OPERATOR>
<!--START_INS_C2.1-->
<OPERATOR type="copy">
<INPUT name="on_off_sale.v"/>
<OUTPUT name="on_sale_out.v"/>
<OUTPUT name="off_sale_out.v"/>
</OPERATOR>
<!--END_INS_C2.1-->
<OPERATOR type="fieldmod">
<INPUT name="on_sale_out.v"/>
<!--START_DIS_C2.1
<PROPERTY name="rename" value="ON_SALE_EFFECTIVE_DATE=STATUS_UPDATE_DATE"/>
END_DIS_C2.1-->
<!--START_INS_C2.1-->
<PROPERTY name="rename" value="ON_SALE_EFFECTIVE_DATE=ONSALE_DATE"/>
<!--END_INS_C2.1-->
<OPERATOR type="export">
<PROPERTY name="outputfile" value="\${ON_SALE_OUTPUT_FILE}"/>
<PROPERTY name="schemafile" value="\${ON_SALE_OUTPUT_SCHEMA}"/>
</OPERATOR>
</OPERATOR>
<OPERATOR type="fieldmod">
<INPUT name="off_sale_out.v"/>
<!--START_DIS_C2.1
<PROPERTY name="rename" value="OFF_SALE_EFFECTIVE_DATE=STATUS_UPDATE_DATE"/>
END_DIS_C2.1-->
<!--START_INS_C2.1-->
<PROPERTY name="rename" value="OFF_SALE_EFFECTIVE_DATE=OFFSALE_DATE"/>
<!--END_INS_C2.1-->
<OPERATOR type="export">
<PROPERTY name="outputfile" value="\${OFF_SALE_OUTPUT_FILE}"/>
<PROPERTY name="schemafile" value="\${OFF_SALE_OUTPUT_SCHEMA}"/>
</OPERATOR>
</OPERATOR>
</FLOW>
EOF
checkerror -e 0 -m "Program failed - check ${ERR_FILE}"
# Remove the status file
if [[ -f \${STATUS_FILE} ]]; then rm \${STATUS_FILE}; fi
message "Program completed successfully"
# cleanup and exit
rmse_terminate 0
EOF1
# Remove all individual xml files
rm outFlow_${PROGRAM_NAME}*.xml
NO_OF_PART=`get_partname $TABLEOWNER |wc -l`
if [ ${NO_OF_PART} -eq 0 ]; then
echo Table not partitioned
create_nopart_flow
time retl -c ${1} -f outFlow_${PROGRAM_NAME}.xml
else
echo Table partitioned
get_partname $TABLEOWNER |while read PARTNAME THREAD_SEQ
do
echo PartName: $PARTNAME POS: $THREAD_SEQ
create_part_flow $THREAD_SEQ ${PARTNAME}
time /app/rms/scripts/rms_retl_aip.sh outFlow_${PROGRAM_NAME}_${THREAD_SEQ}.xml&
echo Running outFlow_${PROGRAM_NAME}_${THREAD_SEQ}.xml ....
sleep 1
#TASKS_RUNNING=`ps -ef|grep retl|grep -v java|grep -v grep|wc -l`
TASKS_RUNNING=`ps -ef |grep ${PROGRAM_NAME} |grep -v java|grep -v grep |wc -l`
echo Running: ${TASKS_RUNNING} Max: ${MAX_THREAD}
while [ "${TASKS_RUNNING}" -ge "${MAX_THREAD}" ]; do
sleep 2
TASKS_RUNNING=`ps -ef |grep ${PROGRAM_NAME} |grep -v java|grep -v grep |wc -l`
done
done
wait
#Concatenate all files
cat ${OUT_DIR}/dm0_src_i_*.dat > ${OUT_DIR}/sm0_onseffdt_ofseffdt.dat
if [ $? -eq 0 ]; then
rm ${OUT_DIR}/sm0_src_i_*.dat
fi
create_full_flow
time dats/item.sh item_sale.xml
fi -
Nested XML: completely confused
Here is my XML with nested <a> tags in the text that
sits in a node. I'm utterly stumped as to how to get at those
<a> tags. The XML is valid, and when I run a standard Spry
loop, none of the nodes with <a> tags will render. If I
delete the <a> tags, the nodes render fine.
Here is my XML, and below is my Spry:
<?xml version="1.0" encoding="iso-8859-1" ?>
<Whats_New>
<Item>
<Date>06/23/08</Date>
<News><a href="edms_document/EDMS/09016fea8046eb26"
target="_blank"><em>P&I
Daily</em></a> reported Oregon Investment Council
selects.</News>
</Item>
<Item>
<Date>06/23/08</Date>
<News>Mentioned in <a
href="edms_document/EDMS/09016fea8046c419"
target="_blank"><em>Ignites</em> report</a> on
Associates research on increased demand for collective investments
trusts.</News>
</Item>
<Item>
<Date>06/18/08</Date>
<News><a href="edms_document/EDMS/09016fea80467d9a"
target="_blank"><em>Austin Business
Journal</em></a> reported on American venture with
ZZZ.</News>
</Item>
<Item>
<Date>06/13/08</Date>
<News>And this is another test <a href="
http://www.cnn.com">to
see</a> if this works.</News>
</Item>
<Item>
<Date>06/09/08</Date>
<News>Liability Investing director was recently quoted
in an <a href="edms_document/EDMS/09016fea804659a4"
target="_blank">article</a> distributed over the
newswire.</News>
</Item>
</Whats_New>
The example page I was looking at is completely confusing. Is
there a straight ahead example or way to go about getting at this?
Is it even possible with this data like this?
Here is my HTML and Spry:
<script type="text/javascript">
var ds_whatsnew = new
Spry.Data.XMLDataSet("xml/index_ds_whatsnew.xml?" + dateForXML(),
"Whats_New/Item");
var ds_ahref = new Spry.Data.NestedXMLDataSet(ds_whatsnew,
"News/a");
</script>
<div spry:region="ds_whatsnew">
<ul>
<li spry:repeat="ds_whatsnew">{Date} -
{News}</li>
</ul>
</div>
I got as far as getting the right .js loaded and a ds named,
but can't figure out what to do next.
Help!
DougNevermind. I realized I needed to just wrap all that in a
CDATA tag and the problem is GONE.
Doug -
XML tag markers moved: Find and Replace causing problem in xml elements
Hi All,
I am doing find and replace using GREP. While using the expression like $1, $2 (Found Items) in the change to field it changes the placement of tag marker. If the found item is a part of two of more xml elements, I am getting a serious problem while replacing it. (ie. The xml tag markers are moved.)
See the screen shot below, then you may get better idea. And help me to overcome this issue.
This is just an example to show you what i'm trying to say, there are so many cases like this.
Original text/ Before doing find replace
After replacing
Green4everHi Peter and John,
but it seems to me that the example is looking for any space that
follows a semi-colon and has two word characters following it, and
repalce that with an em space. I think you could do the same using look
behind and look ahead and not need to replace the found text.
Yes you are right about the look behind and look ahead. I'd like to show some more examples to show what the actual problem is,
Original/Before Replacing,
(Consider there is another case here, instead of em-space some times normal word space will also be there)
Using the Grep:
Find What---------> ^(\d+\.(?:\d+)?)~m
Change To------------->$1\t
After Replace:
Did I make any sense? Eventhough this will not make any changes in the layout, my requirement is to insert the tab out-side the tag marker not indise.
Green4ever -
Urgent help needed for XML Tags using XMLForest()
Folks
I need some urgent help regarding getting use defined tag in your
XML output.
For this I am using XMLElement and XMLForest which seems to work fine
when used at the SQL prompt but when used in a procedure throws and error
SQL> Select SYS_XMLAGG(XMLElement("SDI",
XMLForest(sdi_num)))
From sdi
where sdi_num = 22261;- WORKS FINE
But when used in a procedure,doesnt seem to work
Declare
queryCtx DBMS_XMLQuery.ctxType;
v_xml VARCHAR2(32767);
v_xmlClob CLOB;
BEGIN
v_xml:='Select SYS_XMLAGG(XMLElement("SDI",
XMLFOREST(sdi_num)))
From sdi
where sdi_num = 22261';
queryCtx :=DBMS_XMLQuery.newContext(v_xml);
v_xmlClob :=DBMS_XMLQuery.getXML(queryCtx);
display_xml(v_xmlClob);
End;
CREATE OR REPLACE PROCEDURE display_xml(result IN OUT NOCOPY CLOB)
AS
xmlstr varchar2(32767);
line varchar2(2000);
BEGIN
xmlstr:=dbms_lob.SUBSTR(result,32767);
LOOP
EXIT WHEN xmlstr is null;
line :=substr(xmlstr,1,instr(xmlstr,chr(10))-1);
dbms_output.put_line('.'||line);
xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
END LOOP;
end;
SQL> /
.<?xml version = '1.0'?>
.<ERROR>oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an
XML tag name.</ERROR>
PL/SQL procedure successfully completed.
SQL>HELP is appreciated as to where I am going wrong?Hi,
if you want to transform something to something else, you should declare, what is your source.
I would prefer to use plain XSL-Transformations, because you have a lot more options to transform your source and you can even better determine, how your output should looks like.
Kind regards,
Hendrik
Maybe you are looking for
-
After iTunes recent update I can no longer update any of my free apps that it says have an update ready. When I try it says no updates are available. Everything worked fine until the recent iTunes update. What do I need to do to get it to recognize
-
How I use 2 AI with 1 AO in the same program without hardware errors?
I have a machine with a Motor (velocity controled with PWM), a Strain Gauge, and a Encoder (inner the motor). This machine is controled with a LabVIEW 6.1 program in a computer with Intel Celeron 1.5Gb 360 Mb RAM and DAQ 6024E. In my program I have t
-
PDF files only print as "images"
My computer recently crashed and I was forced to reset it to factory settings and reinstall all my programs and data. I downloaded Acrobat Reader XI, but have been unable to print PDF documents other than as "images." It now takes several minutes t
-
Error while material extension
I am getting below error while extending materials "You want to change the profit center but there are still material stocks". Rakesh
-
How do I create a combined PDF with sepearte sections as in the past Adobe selections. I now have Adobe Acrobate X and I cant find that choice only one combined file.