For xml explicit creating wrong hierarchy
hi we run 2012 std. My query that is generally of the form u see in block 1, which without xml phrase creates flat results u see in block 2 is putting all address info under last contact incorrectly. Does anybody see what i'm doing
wrong?
SELECT 1 AS Tag
,null AS Parent
,NULL AS 'Request!1!'
,NULL AS 'Contacts!2!'
,NULL AS 'Contact!3!'
,NULL AS 'Contact!3!ContactID!Element'
,NULL AS 'ContactAddresses!4!'
,NULL AS 'ContactAddress!5!'
,NULL AS 'ContactAddress!5!Address1!Element'
,NULL AS 'ContactAddress!5!eMail!Element'
UNION ALL
SELECT 2 AS Tag
,1 AS Parent
,NULL AS 'Request!1!'
,NULL AS 'Contacts!2!'
,NULL AS 'Contact!3!'
,NULL AS 'Contact!3!ContactID!Element'
,NULL AS 'ContactAddresses!4!'
,NULL AS 'ContactAddress!5!'
,NULL AS 'ContactAddress!5!Address1!Element'
,NULL AS 'ContactAddress!5!eMail!Element'
UNION ALL
SELECT 3 AS Tag
,2 AS Parent
,NULL AS 'Request!1!'
,NULL AS 'Contacts!2!'
,NULL AS 'Contact!3!'
,LTRIM(RTRIM(x)) AS 'Contact!3!ContactID!Element'
,NULL AS 'ContactAddresses!4!'
,NULL AS 'ContactAddress!5!'
,NULL AS 'ContactAddress!5!Address1!Element'
,NULL AS 'ContactAddress!5!eMail!Element'
FROM ...
UNION ALL
SELECT 4 AS Tag
,3 AS Parent
,NULL AS 'Request!1!'
,NULL AS 'Contacts!2!'
,NULL AS 'Contact!3!'
,ltrim(rtrim(x)) AS 'Contact!3!ContactID!Element'
,NULL AS 'ContactAddresses!4!'
,NULL AS 'ContactAddress!5!'
,NULL AS 'ContactAddress!5!Address1!Element'
,NULL AS 'ContactAddress!5!eMail!Element'
FROM ...
UNION ALL
SELECT 5 AS Tag
,4 AS Parent
,NULL AS 'Request!1!'
,NULL AS 'Contacts!2!'
,NULL AS 'Contact!3!'
,ltrim(rtrim(x)) AS 'Contact!3!ContactID!Element'
,NULL AS 'ContactAddresses!4!'
,NULL AS 'ContactAddress!5!'
,case when y ='' then null else LTRIM(RTRIM(y)) end AS 'ContactAddress!5!Address1!Element'
,LTRIM(RTRIM(z)) AS 'ContactAddress!5!eMail!Element'
FROM ...
FOR XML EXPLICIT
Tag Parent Request!1! Contacts!2! Contact!3! Contact!3!ContactID!Element ContactAddresses!4! ContactAddress!5! ContactAddress!5!Address1!Element ContactAddress!5!eMail!Element
1 NULL NULL NULL NULL NULL NULL NULL NULL NULL
2 1 NULL NULL NULL NULL NULL NULL NULL NULL
3 2 NULL NULL NULL 10 NULL NULL NULL NULL
3 2 NULL NULL NULL 11 NULL NULL NULL NULL
4 3 NULL NULL NULL 10 NULL NULL NULL NULL
4 3 NULL NULL NULL 11 NULL NULL NULL NULL
5 4 NULL NULL NULL 10 NULL NULL Address-1-1 NULL
5 4 NULL NULL NULL 10 NULL NULL Address-1-2 NULL
5 4 NULL NULL NULL 10 NULL NULL NULL [email protected]
5 4 NULL NULL NULL 11 NULL NULL NULL [email protected]
5 4 NULL NULL NULL 11 NULL NULL NULL NULL
<Request>
<Contacts>
<Contact>
<ContactID>10</ContactID>
</Contact>
<Contact>
<ContactID>11</ContactID>
<ContactAddresses />
<ContactAddresses>
<ContactAddress>
<Address1>Address1-1</Address1>
</ContactAddress>
<ContactAddress>
<Address1>Address1-2</Address1>
</ContactAddress>
<ContactAddress>
<eMail>[email protected]</eMail>
</ContactAddress>
<ContactAddress>
<eMail>[email protected]</eMail>
</ContactAddress>
<ContactAddress />
</ContactAddresses>
</Contact>
</Contacts>
</Request>
Hi db042190,
You have to add one more sort column for each statement in the union. The correlation you try to reflect by the column [Contact!3!ContactID!Element] does not effect. The order in the dataset to for xml explict does make sense to shape the xml. Please see below.
CREATE TABLE [dbo].[debugXML](
[ID] [tinyint] IDENTITY(1,1) NOT NULL,
tag int,
parent int,
[sort] int,
[Request!1!] varchar(50),
[Contacts!2!] varchar(50),
[Contact!3!] varchar(50),
[Contact!3!ContactID!Element] int,
[ContactAddresses!4!] varchar(50),
[ContactAddress!5!] varchar(50),
[ContactAddress!5!Address1!Element] varchar(50),
[ContactAddress!5!eMail!Element] varchar(50),
CONSTRAINT [PK_debugXML] PRIMARY KEY CLUSTERED
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
insert dbo.debugXML
select 1 , NULL, 1,NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL
union all select 2 , 1 , 2,NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL
union all select 3 , 2 , 3,NULL , NULL , NULL , 10 , NULL , NULL , NULL , NULL
union all select 3 , 2 , 8,NULL , NULL , NULL , 11 , NULL , NULL , NULL , NULL
union all select 4 , 3 , 4,NULL , NULL , NULL , 10 , NULL , NULL , NULL , NULL
union all select 4 , 3 , 9,NULL , NULL , NULL , 11 , NULL , NULL , NULL , NULL
union all select 5 , 4 , 5,NULL , NULL , NULL , 10 , NULL , NULL , 'Address-1-1' , NULL
union all select 5 , 4 , 6,NULL , NULL , NULL , 10 , NULL , NULL , 'Address-1-2' , NULL
union all select 5 , 4 , 7,NULL , NULL , NULL , 10 , NULL , NULL , NULL , '[email protected]'
union all select 5 , 4 , 10,NULL , NULL , NULL , 11 , NULL , NULL , NULL , '[email protected]'
union all select 5 , 4 , 11,NULL , NULL , NULL , 11 , NULL , NULL , NULL , NULL
SELECT [tag]
,[parent]
,[Request!1!]
,[Contacts!2!]
,[Contact!3!]
,[Contact!3!ContactID!Element]
,[ContactAddresses!4!]
,[ContactAddress!5!]
,[ContactAddress!5!Address1!Element]
,[ContactAddress!5!eMail!Element]
FROM [dbo].[debugXML]
order by sort
for xml explicit
<Request>
<Contacts>
<Contact>
<ContactID>10</ContactID>
<ContactAddresses>
<ContactAddress>
<Address1>Address-1-1</Address1>
</ContactAddress>
<ContactAddress>
<Address1>Address-1-2</Address1>
</ContactAddress>
<ContactAddress>
<eMail>[email protected]</eMail>
</ContactAddress>
</ContactAddresses>
</Contact>
<Contact>
<ContactID>11</ContactID>
<ContactAddresses>
<ContactAddress>
<eMail>[email protected]</eMail>
</ContactAddress>
<ContactAddress />
</ContactAddresses>
</Contact>
</Contacts>
</Request>
A good reading for "FOR XML EXPLICT"
for-xml-explicit-tutorial
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support
Similar Messages
-
SQL Server's FOR XML EXPLICIT functionality in Oracle
What could be the best way to implement SQL Server's FOR XML EXPLICIT functionality? Can someone please give the overview?
Probably you can try General XML forum General XML
Gints Plivna
http://www.gplivna.eu -
WCF-SQL and XML EXPLICIT How to generate a schema from add Generated Items...
Hi
I have a stored procedure in which it returns a select that I have configured using FOR XML EXPLICIT. The query returns in a single column the exact XML that I require.
However, When I add generated items (outbound) in Visual Studio against the SP it only gives me a single element which is the column name (a guid) not the structure of the xml. I have tried FOR XML EXPLICIT, XMLDATA with no luck
Surely there is a way to generate the schema within biztalk for a custom XML structure I want to create.
Thanks
Biztalk DeveloperYes, it is generating you un typed message for the stored procedure . As you are using WCF SQL adapter you don't need to specify the XML auto clause inside your Stored Procedure .
You can also take referece from below MSDN blog
http://blogs.msdn.com/b/biztalkmusings/archive/2009/10/05/a-simple-biztalk-server-2009-wcf-sqlserver-adapter-example.aspx
Thanks
Abhishek -
Generate xml using FOR XML PATH from table with hierarchy
I need to create xml from a table like:
EL1 EL2 EL3 Attr01 Attr02 Attr03 Attr04
E10, , ,a,b,c,d
E10,E1010, ,a,b,c,d
E10,E1010,E101010,a,b,c,d
E10,E1010,E101020,a,b,c,d
E10,E1010,E101030,a,b,c,d
E10,E1020, ,a,b,c,d
E10,E1020,E102010,a,b,c,d
E20, , ,a,b,c,d
E20,E2010, ,a,b,c,d
E20,E2010,E201010,a,b,c,d
E20,E2020, ,a,b,c,d
E20,E2020,E202010,a,b,c,d
E20,E2020,E202020,a,b,c,d
The hierarchy is EL1--EL2--EL3, and the 3 columns should be elements of xml;
The other for columns Attr01,Attr02,Attr03,Attr04 should be attributes of xml;
The actual table could have more than 500 rows(there are many values for El1,EL2,and EL3).
The expected xml should like:
<root>
<E10 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E1010 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E101010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
<E101020 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
<E101030 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
</E1010>
<E1020 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E102010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
</E1020>
</E10>
<E20 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E2010 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E201010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
</E2010>
<E2020 Attr01="a" Attr02="b" Attr03="c" Attr04="d">
<E202010 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
<E202020 Attr01="a" Attr02="b" Attr03="c" Attr04="d" />
</E2020>
</E20>
</root>
I create a sample Src table:
CREATE TABLE Src
EL1 VARCHAR(10),
EL2 VARCHAR(10),
EL3 VARCHAR(10),
Attr01 VARCHAR(10),
Attr02 VARCHAR(10),
Attr03 VARCHAR(10),
Attr04 VARCHAR(10)
GO
INSERT INTO Src
(EL1,EL2,EL3,Attr01,Attr02,Attr03,Attr04
SELECT 'E10','','','a','b','c','d'
UNION SELECT 'E10','E1010','','a','b','c','d'
UNION SELECT 'E10','E1010','E101010','a','b','c','d'
UNION SELECT 'E10','E1010','E101020','a','b','c','d'
UNION SELECT 'E10','E1010','E101030','a','b','c','d'
UNION SELECT 'E10','E1020','','a','b','c','d'
UNION SELECT 'E10','E1020','E102010','a','b','c','d'
UNION SELECT 'E20','','','a','b','c','d'
UNION SELECT 'E20','E2010','','a','b','c','d'
UNION SELECT 'E20','E2010','E201010','a','b','c','d'
UNION SELECT 'E20','E2020','','a','b','c','d'
UNION SELECT 'E20','E2020','E202010','a','b','c','d'
UNION SELECT 'E20','E2020','E202020','a','b','c','d'
GO
I tried to use FOR XML PATH to generate xml for the sample data. When the records increase to a few hundreds, it's not a good idea.
Here is my script:
SELECT
(SELECT Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E101010'
FOR XML PATH('E101010'),TYPE
) AS 'node()'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E101020'
FOR XML PATH('E101020'),TYPE
) AS 'node()'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E101030'
FOR XML PATH('E101030'),TYPE
) AS 'node()'
FROM Src
WHERE EL2 = 'E1010' AND (EL1 <>'' AND EL3 ='')
FOR XML PATH('E1010'),TYPE
) AS 'node()'--1010
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E102010'
FOR XML PATH('E102010'),TYPE
) AS 'node()'
FROM Src
WHERE EL2 = 'E1020' AND (EL1 <>'' AND EL3 ='')
FOR XML PATH('E1020'),TYPE
) AS 'node()'--1020
FROM Src
WHERE EL1 = 'E10' AND (EL2 ='' AND EL3 ='')
FOR XML PATH('E10'),TYPE) 'node()'
,(SELECT Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E201010'
FOR XML PATH('E201010'),TYPE
) AS 'node()'
FROM Src
WHERE EL2 = 'E2010' AND (EL1 <>'' AND EL3 ='')
FOR XML PATH('E2010'),TYPE
) AS 'node()'--2010
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E202010'
FOR XML PATH('E202010'),TYPE
) AS 'node()'
,( SELECT
Attr01 AS '@Attr01'
,Attr02 AS '@Attr02'
,Attr03 AS '@Attr03'
,Attr04 AS '@Attr04'
FROM Src
WHERE EL3 = 'E202020'
FOR XML PATH('E202020'),TYPE
) AS 'node()'
FROM Src
WHERE EL2 = 'E2020' AND (EL1 <>'' AND EL3 ='')
FOR XML PATH('E2020'),TYPE
FROM Src
WHERE EL1 = 'E20' AND (EL2 ='' AND EL3 ='')
FOR XML PATH('E20'),TYPE) AS 'node()'
FOR XML PATH(''),ROOT('root')
If I get a few hundreds of rows, how huge the script should be. Does anyone have better solution for this? Thanks.
TaowBob,
Thanks! And sorry for late feedback.
The XSD requires the xml structures like the following
<Schools>
<School01>Some school</School01>
<School02>Some other school</School02>
</Schools>
I have to use the number in the element name.
Right now I just use the nested FOR XML PATH, although I have to write thousand lines code.
Thanks anyway.
Tao
Tao -
What should i put in Schme while creating Data server for XML
I am new to XML and ODI also.
I was trying to create a data server for XML technology.
I don't know what should i specify as a schmea in JDBC URL.
e.g. jdbc:snps:xml?f=../demo/xml/1/file.xml&ro=false&ldoc=true&case_sens=true&s=LEO_FIZ&dod=true
here schema is LEO_FIZ, so my doubts is LEO_FIZ is a database schema or what ??
Please help me out.The schema referred to here is going to be used by the XML driver for the instantiation of the temporary schema used for the xml data. It can be any name, I recommend you keep it short, as if you use an external database for the XML data instantiation it is used as a part of the "table" names.
-
Error of Creating Data Server for XML
Hi all,
When I want to create a new data server for XML in ODI, the error occur.
error information:
connection failed
java.sql.SQLException: Unexpected token: EMP_TABLE in statement [create EMP_TABLE]
My JDBC url is: jdbc:snps:xml?f=../demo/xml/MOP/MOPEMP.xml&rt=Export&ro=false&case_sens=true&s=EMP
It seems that the error is caused by the schema "EMP". But when I changed the name of schema, the error still occur...
Could you give me some advices about this?
Thanks&Regards
YanHi,
Thans for your reply.
This is the DTD for my xmldoc.
<!ELEMENT Data (Department+)>
<!ELEMENT EmployeeID (#PCDATA)>
<!ATTLIST EmployeeID col (EMPID) #IMPLIED>
<!ELEMENT Education (EmployeeID, Sequence, Dgree)>
<!ATTLIST Education table NMTOKEN #IMPLIED>
<!ELEMENT Employee (EmployeeName, EmployeeID, DepartmentID, Education*)>
<!ATTLIST Employee table NMTOKEN #IMPLIED>
<!ELEMENT EmployeeName (#PCDATA)>
<!ATTLIST EmployeeName col NMTOKEN #IMPLIED>
<!ELEMENT DepartName (#PCDATA)>
<!ATTLIST DepartName col NMTOKEN #IMPLIED>
<!ELEMENT Table (Column+)>
<!ATTLIST Table importType NMTOKEN #IMPLIED>
<!ATTLIST Table parentTable NMTOKEN #IMPLIED>
<!ATTLIST Table tag NMTOKEN #IMPLIED>
<!ATTLIST Table columns NMTOKEN #IMPLIED>
<!ATTLIST Table name NMTOKEN #IMPLIED>
<!ELEMENT DepartID (#PCDATA)>
<!ATTLIST DepartID col NMTOKEN #IMPLIED>
<!ELEMENT MetaData (Table+)>
<!ELEMENT Sequence (#PCDATA)>
<!ATTLIST Sequence col NMTOKEN #IMPLIED>
<!ELEMENT Dgree (#PCDATA)>
<!ATTLIST Dgree col NMTOKEN #IMPLIED>
<!ELEMENT Export (MetaData, Data)>
<!ELEMENT DepartmentID (#PCDATA)>
<!ATTLIST DepartmentID col NMTOKEN #IMPLIED>
<!ELEMENT Column (#PCDATA)>
<!ATTLIST Column deleteKey NMTOKEN #IMPLIED>
<!ATTLIST Column isKey NMTOKEN #IMPLIED>
<!ELEMENT Department (DepartName, DepartID, Employee+)>
<!ATTLIST Department table NMTOKEN #IMPLIED>
Thanks again!
Yan -
Issue in creating data server for xml in ODI
Hi,
I have a XMl which has a size around 95 MB. When i tried to create data server in ODI for this xml file.
I encounter below error,
"oracle.odi.jdbc.datasource.ConnectionTimeoutException: A login timeout occured while connecting to the database
at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter.doGetConnection(LoginTimeoutDatasourceAdapter.java:117)
at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter.getConnection(LoginTimeoutDatasourceAdapter.java:62)
at com.sunopsis.sql.SnpsConnection.testConnection(SnpsConnection.java:1125)
at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.getLocalConnect(SnpsDialogTestConnet.java:163)
at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.access$4(SnpsDialogTestConnet.java:159)
at com.sunopsis.graphical.dialog.SnpsDialogTestConnet$4.doInBackground(SnpsDialogTestConnet.java:520)
at com.sunopsis.graphical.dialog.SnpsDialogTestConnet$4.doInBackground(SnpsDialogTestConnet.java:1)
at oracle.odi.ui.framework.AbsUIRunnableTask.run(AbsUIRunnableTask.java:258)
at oracle.ide.dialogs.ProgressBar.run(ProgressBar.java:656)
at java.lang.Thread.run(Thread.java:662)"
Kindly let me know what should i do for resolving the error.
Thanks and Regards,
Ida Jebakirubai S.Yes Phil i am able to create a data server for xml files which are of smaller in size(in KB). And i can use the files in the interface as well.
When i using this large file only i am getting this error.
Please suggest.
Thanks and Regards,
Ida. -
Hi,
I am trying to create a dataserver for xml using following info:
jdbc driver: com.sunopsis.jdbc.driver.xml.SnpsXmlDriver
jdbc url: jdbc:snps:xml?f=C:/Day_Dim.xml&re=Year&ro=false&case_sens=true
But I am getting following error: "Connection Closed"
Please help.
Thanks,
MonikaHi,
Thans for your reply.
This is the DTD for my xmldoc.
<!ELEMENT Data (Department+)>
<!ELEMENT EmployeeID (#PCDATA)>
<!ATTLIST EmployeeID col (EMPID) #IMPLIED>
<!ELEMENT Education (EmployeeID, Sequence, Dgree)>
<!ATTLIST Education table NMTOKEN #IMPLIED>
<!ELEMENT Employee (EmployeeName, EmployeeID, DepartmentID, Education*)>
<!ATTLIST Employee table NMTOKEN #IMPLIED>
<!ELEMENT EmployeeName (#PCDATA)>
<!ATTLIST EmployeeName col NMTOKEN #IMPLIED>
<!ELEMENT DepartName (#PCDATA)>
<!ATTLIST DepartName col NMTOKEN #IMPLIED>
<!ELEMENT Table (Column+)>
<!ATTLIST Table importType NMTOKEN #IMPLIED>
<!ATTLIST Table parentTable NMTOKEN #IMPLIED>
<!ATTLIST Table tag NMTOKEN #IMPLIED>
<!ATTLIST Table columns NMTOKEN #IMPLIED>
<!ATTLIST Table name NMTOKEN #IMPLIED>
<!ELEMENT DepartID (#PCDATA)>
<!ATTLIST DepartID col NMTOKEN #IMPLIED>
<!ELEMENT MetaData (Table+)>
<!ELEMENT Sequence (#PCDATA)>
<!ATTLIST Sequence col NMTOKEN #IMPLIED>
<!ELEMENT Dgree (#PCDATA)>
<!ATTLIST Dgree col NMTOKEN #IMPLIED>
<!ELEMENT Export (MetaData, Data)>
<!ELEMENT DepartmentID (#PCDATA)>
<!ATTLIST DepartmentID col NMTOKEN #IMPLIED>
<!ELEMENT Column (#PCDATA)>
<!ATTLIST Column deleteKey NMTOKEN #IMPLIED>
<!ATTLIST Column isKey NMTOKEN #IMPLIED>
<!ELEMENT Department (DepartName, DepartID, Employee+)>
<!ATTLIST Department table NMTOKEN #IMPLIED>
Thanks again!
Yan -
Creating custom class instances for XML nodes
Hi guys,
I'm trying to load an external XML document in my application
and create an instance of a custom class for each node in the XML
based on the value of some of their elements. The instances created
will eventually end up in a DataGrid by the way. The problem I'm
having is there seems to be many ways of doing small parts of this
and I have no idea how to make them all gel. Initially I'm using
HTTPService to load the XML file but I've seen people just use an
XML object. Then, after that, I initially set the loaded XML to an
ArrayCollection but others have used XMLList or XMLListCollection.
I've no idea what's the best way to do this.
Eventually, when I've created all of these instances by
looping over the XML and creating them how will I make them
bindable to the data grid? I'm guessing I'll have to group them
somehow...
Any help would be greatly appreciated. ThanksHey Tracy,
That is exactly what I was talking about in a previous post
you replied to
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1344350
Anyhow, Below is some code I created to do what your saying
somewhat dynamically. The idea being you can have many different
object types that you may want to populate with data from XML. In
my case I am using e4x as the result type from my web services. At
present I have about 6 different classes that call this function.
I'd love to get some opinions on the function. Good bad or
???? Any improvements etc????
package . . . .
import flash.utils.describeType;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
import mx.utils.ObjectUtil;
* Utility class to convert xml based Objects to class
instances.
* Takes a value object as the destination and an xmlList of
data
* Look through all the items in the value object. Note we
are using classInfo..accessor since
* our objects are bound all variables become getter /
setter's or accessors.
* Also note, we can handle custom objects, arrays and
arrayCollections.
* History
* 03.11.2008 - Steven Rieger : Created class
public final class XMLToInstance
public static function xmlToInstance( destinationObject :
Object, sourceXMLList : XMLList ) : void
// Get the class definition in XML, from the passed in
object ( introspection so to speak )
var classInfo : XML = describeType( destinationObject );
// Loop through each variable defined in the class.
for each ( var aVar : XML in classInfo..accessor )
// If this is String, Number, etc. . . Just copy the data
into the destination object.
if( isSimple( aVar.@type ) )
destinationObject[aVar.@name] = sourceXMLList[aVar.@name];
else
// Dynamically create a class of the appropriate type
var className : String = aVar.@type;
var ObjectClass : Class = getDefinitionByName( className )
as Class;
var newDestObject : Object = Object( new ObjectClass());
// If this is a custom type
if( isCustomType( className ) && ObjectClass != null
// Recursively call itself passing in the custom data type
and the data to store in it.
// I haven't tested nested objects more than one level. I
suppose it should work.
// Note to self. Check.
xmlToInstance( newDestObject, sourceXMLList[aVar.@name] );
else
// Must be some sort of Array, Array Collection . . .
if( ObjectClass != null )
var anXMLList : XMLList = new XMLList(
sourceXMLList[aVar.@name] );
for each( var anItem : XML in anXMLList )
// I'm sure there are more types, just not using any of them
yet.
if( newDestObject is Array )
newDestObject.push( anItem )
else
newDestObject.addItem( anItem );
// Add the data to the destination object. . . .
destinationObject[aVar.@name] = newDestObject;
} // end function objectToInstance
public static function isSimple( dataType : String ) :
Boolean
* This function is pretty self explanatory.
* Check to see if this is a simple data type. Did I miss
any?
* History
* 03.11.2008 - Steven Rieger : Created function
switch( dataType.toLowerCase() )
case "number":
case "string":
case "boolean":
return true;
return false;
} // end isSimple
public static function isCustomType( className : String ) :
Boolean
* This function is pretty self explanatory.
* Check to see if this is a custom data type. Add them here
as you need. . .
* History
* 03.11.2008 - Steven Rieger : Created function
var aClassName : String = className.replace( "::", "."
).toLowerCase();
aClassName = aClassName.substr( aClassName.lastIndexOf( "."
) + 1, aClassName.length - aClassName.lastIndexOf( "." ) );
switch( aClassName )
case "ndatetimevo":
case "expenselineitemvo":
return true;
return false;
} // end isCustomType
} // end class
} // end package -
Error message at the time create new Hierarchy for Cost Centers (OKEON)
Dear Experts,
we have create new company code with reference to old company code. at the time create new Hierarchy for Cost Center with t code OKEON system given the error message "Overlapping intervals or identical values have occurred".
we have already checked the duplicate entry but not found the same.
Please help.
Regards
BK GAIKWADthe long text to the message is:
Diagnosis
You want to use cost center together with activity type . For this combination, however, no master data record was created in fiscal year . The record is defined in CCA during activity type planning.
System Response
Procedure
1.Create the master data record.
Activity type planning
1.Or, check your entries.
I think you should discuss it with your functional consultant -
Tcode for creating product hierarchy
hello, anybody can give me the Tcode for creating product hierarchy and category
ThanksHi,
Try OVSV (in config)
Steve B -
H2 devide implicit and explicit created indexes by dictionary views?
For migrating amounts of data it is useful to drop and recreate indexes and referencing constaints. A implicit created index by defining a primary/unique key constraint will be dropped implicitly by dropping the before mentioned constraint. Creating such a constraint after creating an equivalent index with the constraint name will result in an other behaviour. The explicit created index will not be dropped by dropping the referencing primary/unique key constraint.
So far so good and well known. The question is: Which dictionary view columns will show me the difference between implicit and explict created indexes if I try to dynamically drop and recreate indexes and unique / primary key constraints?Oracle Version is always helpful in answering questions, but for 9i you can find the system generated by:
dba_indexes.generated = 'Y'
or
'SYS_' naming convention for system generated indexes
or
dba_constraints.constraint_name = dba_constraints.index_name
Hope this helps - JTommaney -
Unable to locate Spring NamespaceHandler for XML schema namespace
I am not sure if this is the best practice approach but this is the problem I am ruining into. Below, I explain what I am doing:
1) What I am doing:
=============
Based on the oracle incubator example (http://coherence.oracle.com/display/INCUBATOR/Processing+Pattern+Examples); I am running a server and submitting tasks through a proxy application that submits them to ProcessingPatternConfigurator; let's call my task processReport.
a) my processReport is using spring and ibatis together, I created a utility static class to obtain a spring context and retrieves beans using the following lines ( see exhibit "A1 and A2" below).
b) when my task calls the context and that spring loads, it is failing with the error show in exhibit "B".
I suspect I am missing a lib? I googled the error and searched you site but could find a meaningful discussion on it. I guess my question is if this is not the best approach, how do I integrated with spring initializing beans and setting up ibatis framwork, providing beans and database access through Ibatis for each task ruining on the grid (processReport).
thanks
A1) processReport (submitted in the grid) uses this line
AbstractXmlApplicationContext ctx = (AbstractXmlApplicationContext) AmrContextUtil.getInstance();
System.out.println("Classpath loaded. Executing Report...");
ReportProcessor repProcessor = (ReportProcessor) ctx.getBean("reportProcessor");
A2) Here is the AmrContextUtil:
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public final class AmrContextUtil {
private static AbstractApplicationContext ctx = null;
public AmrContextUtil() {
super();
public final static synchronized AbstractApplicationContext getInstance(){
if (ctx == null){
ctx = new ClassPathXmlApplicationContext("classpath:config/applicationContext.xml");
setCtx(ctx);
return ctx;
public final static synchronized AbstractApplicationContext getCtx() {
return ctx;
public final static synchronized void setCtx(AbstractApplicationContext ctx) {
AmrContextUtil.ctx = ctx;
B) Here is the error reported by the server:
2010-02-10 15:42:28.312/57.986 Oracle Coherence GE 3.5.2/463 <Warning> (thread=GridExecutor:Thread-2
, member=1): TaskRunner - Failed to process 0x00000126B99E5524AC1F007AAB1587BBCFEC5E6637E1DED6CCB984
03D6AADF4D due to:org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:config/reports-application.xml] Offending resource: class path resource [config/applicationContext.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unexpected failure during bean definition parsing
Offending resource: class path resource [config/reports-application.xml] Bean 'reportSqlMapConfig'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: *Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/util]*
*Offending resource: class path resource [config/reports-application.xml] Bean 'reportSqlMapConfig'*
-> Property 'resourceMap'
c)Here is my application-context.xml offending line:
<bean id="reportSqlMapConfig"
class="com.xx.report.generator.ReportSqlMapConfig">
<property name="resourceMap">
<map>
<entry>
<key>
<util:constant static-field="com.xx.report.domain.ReportType.FPA"/>
</key>
<value>classpath:config/diehardReportSqlMapConfig.xml</value>
</entry>
<entry>
<key>
<util:constant static-field="com.xx.report.domain.ReportType.FCN"/>
</key>
<value>classpath:config/falconReportSqlMapConfig.xml</value>
</entry>
<entry>
<key>
<util:constant static-field="com.xx.report.domain.ReportType.ODS"/>
</key>
<value>classpath:config/odsReportSqlMapConfig.xml</value>
</entry>
</map>
</property>
</bean>My guess is that something is broken in the configuration of the cacheServer and its not finding
all of the dependencies that your process pattern application needs. Probably the best way
to debug this stuff is to define a static main in your runnable task which will make the call
to the run() method and invoke it as the main class using the identical settings (classpath,
run directory) that you are using to launch the Coherence cache server.
Regards,
Bob -
XSLT samples for XML- ABAP mapping
Hi all,
Does anyone have a XSLT samples for XML->ABAP mapping ?
regardsfirst create XSLT program by copy pasting the below given code and give the program name as "Y_TEST"
<b>XSLT code</b>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>
<xsl:template match="NewDataSet">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<OUTTAB>
<xsl:for-each select="Table">
<OUTTAB1>
<AIRPORTCODE>
<xsl:value-of select="AirportCode"/>
</AIRPORTCODE>
<CITYOFAIRPORTNAME>
<xsl:value-of select="CityOrAirportName"/>
</CITYOFAIRPORTNAME>
<COUNTRY>
<xsl:value-of select="Country"/>
</COUNTRY>
<COUNTRYABBRIVATION>
<xsl:value-of select="CountryAbbrviation"/>
</COUNTRYABBRIVATION>
<COUNTRYCODE>
<xsl:value-of select="CountryCode"/>
</COUNTRYCODE>
<GMTOFFSET>
<xsl:value-of select="GMTOffset"/>
</GMTOFFSET>
<RUNWAYLENGTHFEET>
<xsl:value-of select="RunwayLengthFeet"/>
</RUNWAYLENGTHFEET>
<RUNWAYELEVATIONFEET>
<xsl:value-of select="RunwayElevationFeet"/>
</RUNWAYELEVATIONFEET>
<LATITUDEDEGREE>
<xsl:value-of select="LatitudeDegree"/>
</LATITUDEDEGREE>
<LATITUDEMINUTE>
<xsl:value-of select="LatitudeMinute"/>
</LATITUDEMINUTE>
<LATITUDESECOND>
<xsl:value-of select="LatitudeSecond"/>
</LATITUDESECOND>
<LATITUDENPEERS>
<xsl:value-of select="LatitudeNpeerS"/>
</LATITUDENPEERS>
<LONGITUDEDEGREE>
<xsl:value-of select="LongitudeDegree"/>
</LONGITUDEDEGREE>
<LONGITUDEMINUTE>
<xsl:value-of select="LongitudeMinute"/>
</LONGITUDEMINUTE>
<LONGITUDESECONDS>
<xsl:value-of select="LongitudeSeconds"/>
</LONGITUDESECONDS>
<LONGITUDEEPERW>
<xsl:value-of select="LongitudeEperW"/>
</LONGITUDEEPERW>
</OUTTAB1>
</xsl:for-each>
</OUTTAB>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:stylesheet>
<b>just create a type 1 program and paste the below given code.</b>
report y_consume_webservice .
data: wf_user type string .
data: wf_password type string .
types: begin of outtab1 ,
airportcode(6) ,
cityofairportname(50),
country(30) ,
countryabbrivation(10),
countrycode(6) ,
gmtoffset(10) ,
runwaylengthfeet(15),
runwayelevationfeet(15),
latitudedegree(10) ,
latitudeminute(10) ,
latitudesecond(10) ,
latitudenpeers(10) ,
longitudedegree(10) ,
longitudeminute(10) ,
longitudeseconds(10) ,
longitudeeperw(10) ,
end of outtab1 .
data: outtab type table of outtab1.
data: wf_o like line of outtab .
data: g_okcode like sy-ucomm .
data: my_container type ref to cl_gui_custom_container .
data: g_dock type ref to cl_gui_docking_container .
data: mygrid type ref to cl_gui_alv_grid .
data: wf_field_cat type lvc_t_fcat .
data: wf_field_cat_wa like line of wf_field_cat ,
wf_is_layout type lvc_s_layo .
data: wf_fld_cat type slis_t_fieldcat_alv .
data: wf_fld_cat_wa like line of wf_fld_cat .
data: wf_repid like sy-repid .
data: int_tab_name type slis_tabname .
data: xslt_err type ref to cx_xslt_exception .
constants:
* encoding for download of XML files
encoding type string value 'utf-8' .
data: rlength type i,
txlen type string .
data: http_client type ref to if_http_client .
data: wf_string type string .
data: wf_string1 type string .
data: wf_proxy type string ,
wf_port type string .
selection-screen: begin of block a with frame .
parameters: uri2(132) type c lower case .
selection-screen skip 1.
parameters: user(50) lower case,
password(50) lower case ,
p_proxy(100) lower case default 'proxy.xxx.com' ,
p_port(4) default '80'.
selection-screen: end of block a .
at selection-screen output.
loop at screen.
if screen-name = 'PASSWORD'.
screen-invisible = '1'.
modify screen.
endif.
endloop.
start-of-selection .
clear wf_string .
concatenate
'<?xml version="1.0" encoding="utf-8"?>'
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
'<soap:Body>'
'<GetAirportInformationByCountry xmlns="http://www.webserviceX.NET">'
'<country>' uri2 '</country>'
'</GetAirportInformationByCountry>'
'</soap:Body>'
'</soap:Envelope>'
into wf_string .
clear :rlength , txlen .
rlength = strlen( wf_string ) .
move: rlength to txlen .
clear: wf_proxy, wf_port .
move: p_proxy to wf_proxy ,
p_port to wf_port .
call method cl_http_client=>create
exporting
host = 'www.webservicex.net'
service = '80'
scheme = '1'
proxy_host = wf_proxy
proxy_service = wf_port
importing
client = http_client.
http_client->propertytype_logon_popup = http_client->co_disabled.
wf_user = user .
wf_password = password .
call method http_client->authenticate
exporting
proxy_authentication = 'X'
username = wf_user
password = wf_password.
call method http_client->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.
call method http_client->request->set_header_field
exporting
name = '~server_protocol'
value = 'HTTP/1.1'.
call method http_client->request->set_header_field
exporting
name = '~request_uri'
value = '/airport.asmx'.
call method http_client->request->set_header_field
exporting
name = 'Content-Type'
value = 'text/xml; charset=utf-8'.
call method http_client->request->set_header_field
exporting
name = 'Content-Length'
value = txlen.
call method http_client->request->set_header_field
exporting
name = 'SOAPAction'
value = 'http://www.webserviceX.NET/GetAirportInformationByCountry'.
call method http_client->request->set_cdata
exporting
data = wf_string
offset = 0
length = rlength.
call method http_client->send
exceptions
http_communication_failure = 1
http_invalid_state = 2.
call method http_client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
clear wf_string1 .
wf_string1 = http_client->response->get_cdata( ).
replace all occurrences of
'<' in wf_string1 with '<' .
replace all occurrences of
'>' in wf_string1 with '>' .
replace all occurrences of
'xmlns=' in wf_string1 with 'xmlns:xsl=' .
try .
call transformation (`Y_TEST`)
source xml wf_string1
result outtab = outtab.
catch cx_xslt_exception into xslt_err.
data: s type string.
s = xslt_err->get_text( ).
write: ': ', s.
stop.
endtry .
break-point .
Try this and give me your feedback.
Regards
Raja -
Namespace and prefix are not coming up in xml payload created from BSSV
Hello
I am facing this issue that when I am creating xml payload from BSSV, payload does not have namespace and no prefix. I googled on this and made code change in package-info. java file. Now, when I test BSSV locally from Jdeveloper xml gets created with namespace but when I run it from server, there's no namespace.
Does this file package-info.java gets deployed on server? is it ok to make change to it? If not, then what is the other way to resolve this issue?
Please suggest.
Thanks
TKHi Peter,
Thanks for the valuable input.
We have already implemented note 378648 i.e these all parameters are already there under sidadm user in DB node.
BR_OFS=1
BR_OFS_RESOURCE=< database_resource_name>
BR_OFS_CLUSTER=< cluster_name>
BR_OFS_USER=<user_name>
BR_OFS_DOMAIN=<domain>
BR_OFS_PWD=<password>
registry HKEY_LOCAL_MACHINE/Software/Oracle/HomeX ORA_<SID>_AUTOSTART is having value false.
Please guide what could be the other possible reason?
Regards
Praveen
Maybe you are looking for
-
Condition type in Billing not in Sales Order
Dear Friends, I have the following scenario in our project. Please clarify. We have a condition type. That should be appeared only in Billing, it should not appear in Sales Order. Please answer ASAP. Regards, Rajesh L
-
Sent emails are not saving in MAIL
Hi Guys. How can I fix this. Have a look at the attached image - my emails that are sent are not being saved, how can i fix this. http://i28.tinypic.com/2vtwdpw.png It shows last june 19th but I sent many emails today & yesterday. Thanks. -Joey
-
I had Photo Shop 2 installed and I can't type on it. How do I get the keyboard to work?
I have Photo Shop 2 installed on my MacBook Pro. I cannot get the keyboard to type on my photoshop. How do I correct this?
-
My iPhone not recognizing SIM Card
I Have an iPhone 4. Since few days my iPhone is not recognizing my SIM Card. I tried all the suggustions for the net but none worked out. How can I recover my iPhone from this problem?
-
How can I turn off dashboard from middle click on magic mouse?
As the title says: Whenever I have a gesture set up on my magic mouse to hit middle click, it automatically does the dashboard. This I don't want, and I cannot for the life of me work out how the **** to disable the dashboard from middle click. Any