XML Includes and XMLPArse()
I have an XML file that has the following at the top:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MyDtd[
<!ENTITY getInclude SYSTEM "thisInclude.xml">
]>
Later on in the file I call the include:
<product>
<name>productName</name>
<version>ProductVersion</version>
&getInclude;
</product>
Both the parent and the include XML files are properly
formated and when I open the parent or even just the include in a
browser they render correctly. However, when I use Coldfusion's XML
Parse():
<cfscript>
Request.myXML = XmlParse(expandPath('/config/config.xml'));
</script>
<cfdump var="#Request.myXML#">
the results are incorrect. What I get back is this "[unknown
type]". However, if I remove the
&getInclude; the page renders fine. So far I must
conclude that XMLParse() cannot handle XML Includes. This isn't
anything new. Includes inXML has been around for awhile. I can't be
the first to encounter this am I? Is there something I'm missing or
not aware of that's preventing this from working?
quote:
Originally posted by:
little seal
I guess the question now changes to: Can XMLPArse() handle
XML includes or External entities? And as it is now, it would seem
that it can't.
Yes, after rummaging through my archives, that appears to be
the case. You will have to use java or some other workaround until
this is fixed in CF8.
Similar Messages
-
Regular Expressions, include and exclude xml-files
Hi!
I have a javaprogram that should read xml-files from a directory. The program could contain several types of files but it should only read files with a certain pattern.
The file names will look like this:
"resultset_27_23.xml"
where the numbers will change, but the rest of the file name is the same (resultset_XX_XX.xml).
But in the same directory it will also be files with the following pattern:
"resultset_27_23_attachment1.xml"
Here, the numbers could change in the in the same way as the files above, and the number after the text (attachment) could also differ from file to file.Those files should not be read by the program.
I have tried to write a regular expression pattern that only reads the first file types, and exlcudes the other ones, but it won�t work.
Does anyone have a solution to my problem? It is possible to use either just one pattern, or two patterns; one for the files that should be included, and one for the files that should be excluded.So you only want files that match resultset_XX_XX.xml? Will the numbers always be two digits each? Assuming so:
"^resultset_\\d\\d_\\d\\d.xml$"Depending which methods you use, the ^ and $ may or may not be necessary.
If that's not what you meant, please clarify. -
Want to include ?xml tag and schema when creating XML
My database table that need to be generated in to XML are large and therefore I must use OracleXMLQuery.getXMLSAX . The output is missing the <?xml version="1.0" ?> tag. How do I get it? I am on 9i but have imported the .jar containing oracle/xml/parser/v2/XMLSAXSerializer from 10g XDK.
Also, I want the schema to be written next, before the actual XML table values.
I know that a command line parameter exists, which works for small XML files:
java oraclexml getxml -user "scott/tiger" -withDTD "select ....
How do I get the equivalent of '"-withDTD" when using
OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from "+table_name );
qry.getXMLSAX(myStream);
myStream.flush();
Thank you,
ElaineNo. Actually, I can get the <?xml tag and DTD if my select statement contains 'where rownum=0', as the resultset is small which lets me use getXMLMetaData() .
I write it to one output file, then do another OracleXMLQuery, repeating the select statement without the where clause, and run that through getXMLSAX to get the detail.
Next, I need to scrub the data of special characters acceptable in the database but which cause problems to a browser or XML validator. (e.g. accented characters).
Finally, I will concatente the two files.
Is there a simpler way to do this?
Thanks,
Elaine -
How can I take the part that parses the .XML file and make it a procedure.
CREATE OR REPLACE PACKAGE BODY XMLSTUD6 AS
Author: Jimmy Harris
Created: 5/25/2006
Purpose: 1.This package has an XML file initialized to a variable called DOC .
2.It will then take the values from the XML file and insert them into a PL/SQL table.
3.From the PL/SQL table it will insert values into the STUDENTS table.
4.After step four above, the STUDLOAD procedure will insert (Sequence,Status, .XML file, USER, SYSDATE, ERROR_Message
into the AUDIT_XMLSTUD table regardless if insert status was successfull or not status is indicated by either an Y or
NO and the original XML filed that was currently processed, the date and user who executed the procedure.
If the status was NO then it will insert the Oracle SQLERRM massage, into the REASON_FOR_ERROR column.
If status is Y then REASOK_FOR_ERROR IS NULL.
5,Make sure you embed the xml file with an inner and outer ' ' ie: ' the whole .xml file string ' as the input
parameter into the STUDLOAD procedure.
This package excepts the whole .XML file as a CLOB as an input parameter, so that the end-user will not have
modify the code.
Modification History: 1.6/09/2006 JImmy Harris Modified code, added the Function "WORD_CONVERTER1" to accept the requested text data and
return a coded value back to our Welligent system.
2. Was advised that a front end type of functionality was not neccesary for this issue so I removed the INSERT_XML_FILE,
UPDATE_XML_FILE and the INSERT_XML_file.
FUNCTION WORD_CONVERTER1 (v_domain IN VARCHAR2 := null,
v_incoming IN VARCHAR2 := null) RETURN VARCHAR2 IS
v_well VARCHAR2(32);
v_editdd BOOLEAN;
v_code VARCHAR2(32);
CURSOR C_conv_wrd IS
SELECT WELL
INTO v_code
FROM CONVERSION_TABLE
WHERE DOMAIN = UPPER(TRIM(v_domain))
AND INCOMING = UPPER(TRIM(v_incoming));
BEGIN
OPEN c_conv_wrd;
LOOP
FETCH c_conv_wrd INTO v_code;
EXIT WHEN c_conv_wrd%NOTFOUND;
END LOOP;
CLOSE c_conv_wrd;
RETURN v_code;
END WORD_CONVERTER1;
PROCEDURE STUDLOAD (DOC CLOB) IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
v_mm NUMBER;
v_dd NUMBER;
v_yyyy NUMBER;
v_DATE DATE;
v_race VARCHAR2(1);
v_eth VARCHAR2(1);
v_prim_lang VARCHAR2(1);
v_house_lang VARCHAR2(1);
v_gender VARCHAR2(1);
TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
s_tab stuxml_type := stuxml_type();
v_success VARCHAR2(200);
v_failure VARCHAR2(200);
l_error_code varchar2(200);
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
xmlparser.setValidationMode(v_parser, FALSE);
-- Parse the document and create a new DOM document.
SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
v_doc := SYS.XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the STUD nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent');
-- Loop through the list and create a new record in a table collection for each STUD record.
FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, stud);
s_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/LastName');
s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/FirstName');
s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/MiddleName');
v_dd := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Day');
v_mm := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Month');
v_yyyy := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Year');
v_DATE := TO_DATE(v_mm||' '||v_dd||' '||v_yyyy,'MMDDYYYY');
s_tab(s_tab.last).STUDENT_DOB := v_date;
s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/Street');
s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ApartmentNumber');
s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/County');
s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/State');
s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ZipCode');
v_race := WORD_CONVERTER1('RACE',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Race')));
v_eth := WORD_CONVERTER1('EHTNICITY',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Ethnicity')));
v_prim_lang:= WORD_CONVERTER1('PRIMARY_LANG',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/PrimaryLanguage')));
v_house_lang:= WORD_CONVERTER1('SECONDARY_LANG',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/HouseholdLanguage')));
v_gender := WORD_CONVERTER1('GENDER',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Gender')));
s_tab(s_tab.last).STUDENT_RACE := v_race;
s_tab(s_tab.last).STUDENT_ETHNIC := v_eth;
s_tab(s_tab.last).STUDENT_PRI_LANG :=v_prim_lang;
s_tab(s_tab.last).STUDENT_SEC_LANG := v_house_lang;
s_tab(s_tab.last).STUDENT_GENDER :=v_gender;
END LOOP;
FOR stud IN s_tab.first..s_tab.last LOOP
INSERT INTO STUDENTS (SHISID, SSN, DOE_SCHOOL_NUMBER,PATIENT_TYPE, TEACHER, HOMEROOM,STUDENT_LAST_NAME, STUDENT_FIRST_NAME, STUDENT_MI,STUDENT_DOB,
STUDENT_BIRTH_CERT, STUDENT_COMM,STUDENT_MUSA, STUDENT_FAMSIZE, STUDENT_FAMINCOME,STUDENT_UNINSURED, STUDENT_LUNCH, STUDENT_ZIP,STUDENT_STATE,
STUDENT_COUNTY, STUDENT_STREET,STUDENT_APART_NO, STUDENT_PHONE, STUDENT_H2O_TYPE,STUDENT_WASTE_TRT, STUDENT_HOME_SET, STUDENT_NONHOME_SET,
STUDENT_GENDER, STUDENT_RACE, STUDENT_ETHNIC,STUDENT_PRI_LANG, STUDENT_SEC_LANG, STUDENT_ATRISK,EMER_COND_MEMO, ASSIST_DEVICE_TYPE,
SCHOOL_ENTER_AGE,STUDENT_CURR_GRADE, S504_ELIG_DATE, S504_DEV_DATE,S504_REV_DATE, STUDENT_504, STUDENT_IEP,IEP_EXP_DATE, GRAD_CLASS, TYPE_DIPLOMA,
GRADE_RETAIN, LIT_PASS_TEST_MATH, LIT_PASS_DATE_MATH,LIT_PASS_TEST_WRITE, LIT_PASS_DATE_WRITE, LIT_PASS_TEST_READ,LIT_PASS_DATE_READ, SPEC_ED_ELIG,
SPEC_ED_CODE,TRANSPORT_CODE, TRANSPORT_NO, PRIME_HANDICAP,PRIME_HANDICAP_PERCENT, PRIME_HANDI_MANAGER, FIRST_ADD_HANDI,FIRST_ADD_HANDICAP_PERCENT,
FIRST_ADD_HANDI_504, FIRST_ADD_HANDI_504_DATE, SECOND_ADD_HANDI, SECOND_ADD_HANDICAP_PERCENT, MED_EXTERNAL_NAME, INS_TYPE, INS_PRI, INS_NAME,
INS_MEDICAID_NO, ELIGDATE, INS_PRIV_INSURANCE, INS_APPR_BILL, INS_APPR_DATE, INS_PARENT_APPR,INS_POL_NAME, INS_POL_NO, INS_CARRIER_NO,
INS_CARRIER_NAME, INS_CARRIER_RELATE, INS_AFFECT_DATE, INS_COPAY_OV, INS_COPAY_RX, INS_COPAY_AMBUL,INS_COPAY_EMER, INS_COPAY_OUTPAT,STUDENT_INACTIVE,
PHYS_ID, ENCOUNTERNUM,USERID,MODDATE, STUDENT_ID, S504_DISABILITY,CHAPTER1, WELLNESS_ENROLL, SCHOOL_OF_RESIDENCE,INITIAL_IEP_DATE, CALENDAR_TRACK,
USA_BORN,ALT_ID, FUTURE_SCHOOL, IEP_LAST_MEETING,IEP_LAST_SETTING, IEP_LAST_REFER_EVAL, THIRD_ADD_HANDI,LEP, GIFTED, IEP_EXIT_REASON,
CASE_MANAGER_ID, INTAKE_NOTES, CALLER_PHONE,CALL_DATE, CALLER_RELATIONSHIP, CALLER_NAME,BUSINESS_PHONE, FAX, EMAIL,HIGHEST_EDUCATION, INTAKE_DATE,
SERVICE_COORDINATOR, DISCHARGE_DATE, DISCHARGE_REASON, DISCHARGE_NOTES,INTAKE_BY, INTAKE_STATUS, IEP_LAST_SERVED_DATE,IEP_APC_DATE, IEP_EXIT_DATE,
ADDRESS2, LEGAL_STATUS, RELIGION, EMPLOYMENT_STATUS, TARG_POP_GROUP1, TARG_POP_GROUP2, MARITAL_STATUS,THIRD_ADD_HANDI_PERCENT, LAST_INTERFACE_DATE,
SERVICE_PLAN_TYPE,CURRENT_JURISDICTION, FIPS, BIRTH_PLACE_JURISDICTION,BIRTH_PLACE_HOSPITAL, BIRTH_PLACE_STATE, BIRTH_PLACE_COUNTRY,
OTHER_CLIENT_NAME, SIBLINGS_WITH_SERVICES, PERM_SHARE_INFORMATION,PERM_VERIFY_INSURANCE, REFERRING_AGENCY, REFERRING_INDIVIDUAL,AUTOMATIC_ELIGIBILITY,
INTAKE_IEP_ID, FUTURE_SCHOOL2,FUTURE_SCHOOL3, TRANSLATOR_NEEDED, TOTAL_CHILDREN_IN_HOME,REFERRED_BY, FAMILY_ID, SCREENING_CONSENT_FLAG,PICTURE_FILE,
DUAL_ENROLLED, DOE_SCHOOL_NUMBER2)
VALUES (123456789025, null,null ,null,null,null ,s_tab(stud).STUDENT_LAST_NAME,s_tab(stud).STUDENT_FIRST_NAME,s_tab(stud).STUDENT_MI,
s_tab(stud).STUDENT_DOB,null ,null,null ,null,null,null,null,s_tab(stud).STUDENT_ZIP,s_tab(stud).STUDENT_STATE ,s_tab(stud).STUDENT_COUNTY,
s_tab(stud).STUDENT_STREET,s_tab(stud).STUDENT_APART_NO,null,null,null ,null , null,
s_tab(stud).STUDENT_GENDER ,s_tab(stud).STUDENT_RACE , s_tab(stud).STUDENT_ETHNIC,
s_tab(stud).STUDENT_PRI_LANG ,s_tab(stud).STUDENT_SEC_LANG, null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null, null,null );
END LOOP;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,DOC,'Y',NULL,SYSDATE);
HTP.HTMLOPEN;
v_success:= 'The values from the .XML file have been successfully inserted into the STUDENTS table in the Oracle Database.';
htp.bold(v_success);
HTP.HTMLCLOSE;
COMMIT;
-- Free any resources associated with the document now it that it is no longer needed.
xmldom.freeDocument(v_doc);
EXCEPTION
WHEN OTHERS THEN
l_error_code := SQLERRM;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,nvl(DOC,TO_CLOB('No .XML file entered, user pressed button without entering correct information.')),'NO',l_error_code,SYSDATE);
HTP.HTMLOPEN;
v_failure:= 'The attempt made to insert files to the Student table has failed because,'||l_error_code;
htp.bold(v_failure);
HTP.HTMLCLOSE;
COMMIT;
END STUDLOAD;
PROCEDURE UPDSTUDLOAD (DOC CLOB) IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
v_mm NUMBER;
v_dd NUMBER;
v_yyyy NUMBER;
v_DATE DATE;
v_race VARCHAR2(1);
v_eth VARCHAR2(1);
v_prim_lang VARCHAR2(1);
v_house_lang VARCHAR2(1);
v_gender VARCHAR2(1);
TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
s_tab stuxml_type := stuxml_type();
v_success VARCHAR2(200);
v_failure VARCHAR2(200);
l_error_code varchar2(200);
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
xmlparser.setValidationMode(v_parser, FALSE);
-- Parse the document and create a new DOM document.
SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
v_doc := SYS.XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the STUD nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent');
-- Loop through the list and create a new record in a table collection for each STUD record.
FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, stud);
s_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/LastName');
s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/FirstName');
s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/MiddleName');
v_dd := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Day');
v_mm := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Month');
v_yyyy := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Year');
v_DATE := TO_DATE(v_mm||' '||v_dd||' '||v_yyyy,'MMDDYYYY');
s_tab(s_tab.last).STUDENT_DOB := v_date;
s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/Street');
s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ApartmentNumber');
s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/County');
s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/State');
s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ZipCode');
v_race := WORD_CONVERTER1('RACE',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Race')));
v_eth := WORD_CONVERTER1('EHTNICITY',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Ethnicity')));
v_prim_lang:= WORD_CONVERTER1('PRIMARY_LANG',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/PrimaryLanguage')));
v_house_lang:= WORD_CONVERTER1('SECONDARY_LANG',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/HouseholdLanguage')));
v_gender := WORD_CONVERTER1('GENDER',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Gender')));
s_tab(s_tab.last).STUDENT_RACE := v_race;
s_tab(s_tab.last).STUDENT_ETHNIC := v_eth;
s_tab(s_tab.last).STUDENT_PRI_LANG :=v_prim_lang;
s_tab(s_tab.last).STUDENT_SEC_LANG := v_house_lang;
s_tab(s_tab.last).STUDENT_GENDER :=v_gender;
END LOOP;
FOR stud IN s_tab.first..s_tab.last LOOP
UPDATE STUDENTS
SET
STUDENT_LAST_NAME = s_tab(stud).STUDENT_LAST_NAME,
STUDENT_FIRST_NAME = s_tab(stud).STUDENT_FIRST_NAME,
STUDENT_MI = s_tab(stud).STUDENT_MI,
STUDENT_DOB = s_tab(stud).STUDENT_DOB,
STUDENT_ZIP = s_tab(stud).STUDENT_ZIP,
STUDENT_STATE = s_tab(stud).STUDENT_STATE,
STUDENT_COUNTY = s_tab(stud).STUDENT_COUNTY,
STUDENT_STREET = s_tab(stud).STUDENT_STREET,
STUDENT_APART_NO = s_tab(stud).STUDENT_APART_NO
WHERE SHISID = 123456789025;
END LOOP;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,DOC,'Y',NULL,SYSDATE);
HTP.HTMLOPEN;
v_success:= 'The updated .XML file has been successfully saved to the STUDENTS table in the Oracle Database.';
htp.bold(v_success);
HTP.HTMLCLOSE;
COMMIT;
-- Free any resources associated with the document now it that it is no longer needed.
xmldom.freeDocument(v_doc);
EXCEPTION
WHEN OTHERS THEN
l_error_code := SQLERRM;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,nvl(DOC,TO_CLOB('No .XML file entered, user pressed button without entering correct information.')),'NO',l_error_code,SYSDATE);
HTP.HTMLOPEN;
v_failure:= 'The attempt made to insert files to the Student table has failed because,'||l_error_code;
htp.bold(v_failure);
HTP.HTMLCLOSE;
COMMIT;
END UPDSTUDLOAD;
PROCEDURE DELSTUDLOAD (DOC CLOB) IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
v_mm NUMBER;
v_dd NUMBER;
v_yyyy NUMBER;
v_DATE DATE;
TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
s_tab stuxml_type := stuxml_type();
v_success VARCHAR2(200);
v_failure VARCHAR2(200);
l_error_code varchar2(200);
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
xmlparser.setValidationMode(v_parser, FALSE);
-- Parse the document and create a new DOM document.
SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
v_doc := SYS.XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the STUD nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent');
-- Loop through the list and create a new record in a table collection for each STUD record.
FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, stud);
s_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/LastName');
s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/FirstName');
s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/MiddleName');
v_dd := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Day');
v_mm := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Month');
v_yyyy := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Year');
v_DATE := TO_DATE(v_mm||' '||v_dd||' '||v_yyyy,'MMDDYYYY');
s_tab(s_tab.last).STUDENT_DOB := v_date;
s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/Street');
s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ApartmentNumber');
s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/County');
s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/State');
s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ZipCode');
END LOOP;
FOR stud IN s_tab.first..s_tab.last LOOP
DELETE FROM STUDENTS
WHERE SHISID = 123456789025;
END LOOP;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,DOC,'Y',NULL,SYSDATE);
HTP.HTMLOPEN;
v_success:= 'The .XML file has been successfully deleted from the STUDENTS table in the Oracle Database.';
htp.bold(v_success);
HTP.HTMLCLOSE;
COMMIT;
-- Free any resources associated with the document now it that it is no longer needed.
xmldom.freeDocument(v_doc);
EXCEPTION
WHEN OTHERS THEN
l_error_code := SQLERRM;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,nvl(DOC,TO_CLOB('No .XML file entered, user pressed button without entering correct information.')),'NO',l_error_code,SYSDATE);
HTP.HTMLOPEN;
v_failure:= 'The attempt made to insert files to the Student table has failed because,'||l_error_code;
htp.bold(v_failure);
HTP.HTMLCLOSE;
COMMIT;
END DELSTUDLOAD;
END XMLSTUD6;Try opening the problem files using a text editor or file viewer to see what the first few bytes contain. All valid FM binary files for FM 11 will contain <MakerFile 11.0> in the first bytes of the file.
When updating books, it's sometimes better to just to create a new book file and add the files to that.
When renaming files in a book, changes at the system level will break any links/cross-references between files, so it's always best to use the Rename option in the Book file to change FM file names. This will maintain the correct linkages. -
Problem with XML loading and xmlns
I'm having a problem with loading an XML file that was created by Filemaker. Filemaker will output an XML file using one of two different grammars. One outputs in a mostly standard form that I can use with one glitch. Flash CS4 AS3 seems to have a problem with the xmlns in one of the nodes.
Specifically:
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
If I remove the xmlns="http://www.filemaker.com/fmpdsoresult" the file loads properly and I can access the various fields with no problem. However, when I leave the xmlns=... in, it will trace out the XML properly but I can't access the fields using the code listed below. This is driving me crazy!
With the xmlns part in the XML file I get the following error when it tries to load the thumbnail files:
TypeError: Error #1010: A term is undefined and has no properties.
I need to have it so that the user can enter/edit data and simply output the XML file from Filemaker and then Flash will load up the unaltered XML file and show the info requested by the user. That is to say I could have the user open the XML file in a word processing application and have them delete the xmlns..., but that is rather cumbersome and not very user friendly.
I've tried every xml.ignore function I could find but it doesn't help. Hopefully someone out there can help
Thanks,
-Mark-
Partial XML:
XML From Filemaker Export:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This grammar has been deprecated - use FMPXMLRESULT instead -->
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
<ERRORCODE>0</ERRORCODE>
<DATABASE>Sport.fp7</DATABASE>
<LAYOUT></LAYOUT>
<ROW MODID="1" RECORDID="1">
<FirstName>Mark</FirstName>
<LastName>Fowle</LastName>
<Sport>Sailing</Sport>
<Medal>None</Medal>
<CourseOfStudy>Design</CourseOfStudy>
<Year>1976-1978</Year>
<HomeState>California</HomeState>
<ImageName>93</ImageName>
</ROW>
</FMPDSORESULT>
AS3 Code:
import fl.containers.UILoader;
var aPhoto:Array=new Array(ldPhoto_0,ldPhoto_1,ldPhoto_2,ldPhoto_3,ldPhoto_4,ldPhoto_5);
var toSet:int=10;//time out set time
var toTime:int=toSet;
var photoPerPage:int=6;
var fromPos:int=photoPerPage;
var imgNum:Number;
//var subjectURL:URLRequest=new URLRequest("testData_FM8.xml");
var subjectURL:URLRequest=new URLRequest("Sports.xml");
var xmlLoader:URLLoader=new URLLoader(subjectURL);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
var subjectXML:XML = new XML();
subjectXML.ignoreWhitespace=true;
subjectXML.ignoreComments=true;
subjectXML.ignoreProcessingInstructions=true;
function xmlLoaded(evt:Event):void {
subjectXML=XML(xmlLoader.data);
if (root.loaderInfo.bytesTotal==root.loaderInfo.bytesLoaded) {
removeEventListener(Event.ENTER_FRAME, xmlLoaded);
trace("XML Data File Loaded");
trace(subjectXML);
} else {
trace("File not Found");
imgNum=2;//subjectXML.ROW.length;
trace(subjectXML);
loadThumb(0);
function loadThumb(startPos:int):void {
var count:Number=aPhoto.length;
trace(subjectXML.DATABASE);
for (var i=0; i<count; i++) {
try{
aPhoto[i].source="images/"+subjectXML.ROW[startPos+i].ImageName+"_main.jpg";
}catch (e:Error){
trace(e);
aPhoto[i].mouseChildren=false;
aPhoto[i].addEventListener(MouseEvent.MOUSE_DOWN, onThumbClick);
trace("Current mem: " + System.totalMemory);
ldAttract.visible=false;
function unloadThumb():void {
var count:Number=aPhoto.length;
for (var i=0; i<count; i++) {
aPhoto[i].unload();
aPhoto[i].removeEventListener(MouseEvent.MOUSE_DOWN, onThumbClick);
trace("Current mem: " + System.totalMemory);
function onThumbClick(evt:MouseEvent) {
var i:Number;
//trace("Thumbnail Clicked " + evt.target.name);
i=findPos(evt.target.name);
ldLrgPhoto.source="images/"+subjectXML.ROW[i+fromPos].LOCAL_OBJECT_ID+"_main.jpg";
ldLrgPhoto.visible=true;
btnPrev.visible=false;
btnNext.visible=false;
gotoAndStop("showPhoto");
function findPos(thumb:String):Number {
var pos:Number;
var count:Number=aPhoto.length;
for (var i:Number=0; i<count; i++) {
if (thumb==aPhoto[i].name) {
pos=i;
return pos;Hi,
I was trying to use xml namespaces, so in my application I receive an XML file from the server. The file has a namespace, so when I parse the file I need to specify the namespace:
I got the following piece of xml:
<ls:exchange xmlns:ls=".../tsw" xmlns:tm="http://kxa">
<ls:projects>
<tm:annotation id="" date="" action="getprojects" status="responseok"/>
<ls:project id="" name="proj" description="..." owner="asss" release="2" />
<ls:projectV id="" version="" creationdate="" modificationdate=""/ >
</ls:project>
</ls:projects>
</ls:exchange>
and the following code
<mx:VBox label="WELCOME" verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:Tree id="tree" dataProvider="{srv.lastResult.project}" labelField="@name" width="300" height="100%" itemOpen="itemOpenEvt(event);" />
</mx:VBox>
So i want to display the content of the xml (project nodes”) in a tree view, but i don’t know how to includes the namespace"ls:" in the data provider “srv.lastResult.project”. can u help me it’s urgent.
sincerly
Celine -
Reading XML file and skip certain elements/attributes??
Hi folks!
Suppose I have a XML file looking like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE dvds SYSTEM "DTDtest.dtd">
<dvds>
<dvd>
<title>
Aliens
</title>
<director>
James Cameron
</director>
<format>
1.85:1
</format>
</dvd>
<dvd>
<title>
X-Men
</title>
<director>
Bryan Singer
</director>
<format>
2.35:1
</format>
</dvd>
</dvds>
In my Java application I want to read this XML file and print it on the screen (including all tags etc). So far, so good. BUT, if I want to skip certain elements, i.e. all information about the dvd 'X-Men', how am I supposed to do this? In other words, I would like my app to skip reading all information about X-Men and continue with the next <dvd>... </dvd> tag. Is this possible?
My code so far is from the XML tutorial from Sun and it looks like this:
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
public class MyXML extends DefaultHandler
public static void main(String argv[]) {
if (argv.length != 1) {
System.err.println("Usage: cmd filename");
System.exit(1);
// Use an instance of ourselves as the SAX event handler
DefaultHandler handler = new MyXML();
// Use the default (non-validating) parser
SAXParserFactory factory = SAXParserFactory.newInstance();
try {
// Set up output stream
out = new OutputStreamWriter(System.out, "UTF8");
// Parse the input
SAXParser saxParser = factory.newSAXParser();
saxParser.parse( new File(argv[0]), handler);
} catch (Throwable t) {
t.printStackTrace();
System.exit(0);
static private Writer out;
//===========================================================
// SAX DocumentHandler methods
//===========================================================
public void startDocument()
throws SAXException
emit("<?xml version='1.0' encoding='UTF-8'?>");
nl();
public void endDocument()
throws SAXException
try {
nl();
out.flush();
} catch (IOException e) {
throw new SAXException("I/O error", e);
* <p>This method prints the start elements including attr.
* @param namespaceURI
* @param lName
* @param qName
* @param attrs
* @throws SAXException
public void startElement(String namespaceURI,
String lName, // local name
String qName, // qualified name
Attributes attrs)
throws SAXException
String eName = lName; // element name
if ("".equals(eName)) eName = qName; // namespaceAware = false
emit("<"+eName);
if (attrs != null) {
for (int i = 0; i < attrs.getLength(); i++) {
String aName = attrs.getLocalName(i); // Attr name
if ("".equals(aName)) aName = attrs.getQName(i);
emit(" ");
emit(aName+"=\""+attrs.getValue(i)+"\"");
emit(">");
public void endElement(String namespaceURI,
String sName, // simple name
String qName // qualified name
throws SAXException
emit("</"+qName+">");
* <p>This method prints the data between 'tags'
* @param buf
* @param offset
* @param len
* @throws SAXException
public void characters(char buf[], int offset, int len)
throws SAXException
String s = new String(buf, offset, len);
emit(s);
//===========================================================
// Utility Methods ...
//===========================================================
// Wrap I/O exceptions in SAX exceptions, to
// suit handler signature requirements
private void emit(String s)
throws SAXException
try {
out.write(s);
out.flush();
} catch (IOException e) {
throw new SAXException("I/O error", e);
// Start a new line
private void nl()
throws SAXException
String lineEnd = System.getProperty("line.separator");
try {
out.write(lineEnd);
} catch (IOException e) {
throw new SAXException("I/O error", e);
Sorry about the long listing... :)
Best regards
/PaulA possibility that comes to mind is to create an XSLT script to do whatever it is you want - and call it from inside the program. The XSLT script can be stashed inside your .jar file by using getClass().getClassLoader().getResource("...")
- David -
How to parse XML Column and insert values into a table
Hello,
I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
The table that needs to be loaded is as follows:
create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
The XML document is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thank you for any help you can offer.First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
EDIT: In your code right here:
select xt.*
3 from Inventory inve,
4 XMLTable('/dataroot/Inventory'
5 PASSING inve.Inv
I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
END EDIT
EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
END EDIT2
drop table InventoryOut;
create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt;
select * from InventoryOut;
select * from v$version;
table INVENTORYOUT dropped.
table INVENTORYOUT created.
Error starting at line 4 in command:
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt
Error at Command Line:8 Column:12
Error report:
SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
PARTNUMBER QTY WHLOCATION
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
If this helps here is the code and output for the creation of the Inventory table itself:
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
directory XMLSRC created.
table INVENTORY dropped.
table INVENTORY created.
1 rows inserted.
INV
<?xml version="1.0" encoding="WINDOWS-1252"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thanks again for your help so far! Hope we can get this working :)
Edited by: 926502 on Apr 11, 2012 2:47 PM
Edited by: 926502 on Apr 11, 2012 2:49 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM -
Parse exisitng xml file and recreate another xml file with different struct
Is it possible in java using dom parser to parse an exisiting xml file and recreate a new xml file from data obtained by parsing old xml file.
I checked on old forum threads and everywhere either parsing xml file has been explained or creating new xml file from scratch has been shown.
Any examples/guidance will be appreciated....The general process is:
Document dom1 = ... // the parsed document
Document dom2 = ... // new document constructed on the fly
Node nD1 = ... // some random node found in dom1
// copy the node from dom1 and associate with dom2
Node nD2 = dom2.importNode(nD1, true);
// ... treat nD2 as a node which can now be inserted into dom2 ...
Node otherD2 = ... // some other node already in dom2
otherD2.appendChild(nD2);Note, in this example the nD1 node is copied (including any sub-nodes) into a new node, nD2. You can alternately move the node from one Document to another using Document.adoptNode(), however this may fail (see the javadoc). -
XML Element of XML Element of XML Element (and so on...)
Here is my XML data (shorted, in a file myFile):
<LiveData>
<Voltage>
<Total>
<VoltageNow>1052</VoltageNow>
</Total>
</Voltage>
<Power>
<Total>
<PowerNow>345</PowerNow>
</Total>
</LiveData>
I would like to get the VoltageNow and PowerNow values, but the following script does not work:
tell application "System Events"
set elem1 to XML element 1 of XML file myFile /*<LiveData>
set power to XML elements of elem1 whose name is "Power"
set total to XML elements of power whose name is "Total"
set powernow to value of XML elements of total whose name is "PowerNow"
end tell
Error: System Events got an error: Can’t make {} into type string.
BTW, I don't want to use XML Element X because the order may change.
What is the correct method to traverse these elements to obtain values?AppleScript can handle the strings, but the System Events XML Suite doesn't work with text strings - it deals with the XML objects, which have name and value properties. The handler can be modified to show the names of an element, but it is just designed to work with the XML Suite.
The contents of an XML file is just text, so you can forgo System Events and just use regular text manipulation statements, or use another tool such as the Satimage XMLLib osax, which is much more robust and does include commands to display the XML object as a string.
By the way, my original handler was designed and tested in Leopard, but I discovered a Snow Leopard bug that alters the way it returns array/list contents. The following script has changes that return the functionality, in addition to a dialog handler that will display lists:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run -- example
set XMLFile to (choose file without invisibles)
show("element value:", (getXMLElement from {XMLFile, "LiveData", "Voltage", "Total", "VoltageNow"}))
end run
to show(label, something)
show an alert for something, formatting lists and records
parameters - label [text]: the alert text
something [mixed]: an item to put in the alert message
returns nothing
if something is not in {null, missing value} then
try -- show the message
if (class of something) is in {list, record} then (something as number) -- force an error
display alert label message (something as text)
on error errorMessage -- lists and records don't format very well, so cheat
set {here, there} to {(offset of "{" in errorMessage), -(offset of "}" in (reverse of text items of errorMessage) as text)}
display alert label message text here thru there of errorMessage
end try
else
display alert label message "*null or missing value*"
end if
end show
to getXMLElement from XMLItems
get the specified element from a simple XML structure by name or index
the number of items is not fixed, but must be at least 2 (the XML file and an XML element)
parameters: XMLItems [list] -
item 1 [text]: the XML file path (Finder or POSIX)
item 2 [mixed]: the XML element name or index (names are case sensitive)
item(s) 3+ [mixed]: sub item(s)
returns [list]: value of the element
try
if (count XMLItems) is less than 2 then error "getXMLElement handler: item list contains too few items"
tell application "System Events"
set theXMLData to contents of XML file ((the first item of XMLItems) as text)
-- get text of theXMLData
set theXMLElement to XML element 1 of theXMLData -- start at the root element
repeat with anItem in rest of XMLItems -- add on the sub items
set anItem to contents of anItem
try
set anItem to anItem as integer -- index number?
end try
set theXMLElement to (get XML element anItem of theXMLElement)
end repeat
try -- return the element(s)
-- return name of XML elements of theXMLElement
set theResult to value of theXMLElement -- SL built-in result variable does not get set
if theResult is missing value then error -- SL does not error on empty or missing value
return theResult
on error errorMessage number errorNumber -- the element is empty, or a list of items
log errorMessage
return value of XML elements of theXMLElement
end try
end tell
on error errorMessage number errorNumber
log errorMessage
-- return null
error "getXMLElement handler: element not found (" & errorNumber & ")"
end try
end getXMLElement</pre> -
XML Forms and URL links in RenderListItem Form
Hello everyone,
I'm new at XML Forms and trying to do my first forms. I have this scenario:
- user fills several entry fields in "Edit" Form, 2 of them include URL Links.
- Every new entry in "RenderListItem" Form lists fields "Title" and URL1 URL2.
In RenderListItem Form, i would like to control the behaviour of these links. Link URL1 should open in a new window, but URL2 should stay in the same browser window.
How can i achieve this ?
Thank you in advance for any help,
NunoHi Nuno,
you can achieve this by changing the XSL file.
Check out this thread for more infos: XML form display in same browser window
Best regards,
Robert -
Include and call an .exe file inside my jar file
Hi.
I want to include an exe file and call it inside my jar file. this is the code.
InputStream is = getClass().getResourceAsStream("/native/my.exe");
int[] line = new int[is.available()];
File myFile = File.createTempFile("my","exe");
myFile.deleteOnExit();
myFile.setExecutable(true);
FileOutputStream out = new FileOutputStream(myFile.getAbsolutePath());
int i = 0;
int c;
while((c=is.read()) != -1){
line=c;
i++;
is.close();
for(int j= 0;j<line.length;j++)
out.write(line[j]);
out.close();
So i store it in my temp folder. Than i run
String myFileLocation = myFile.getAbsolutePath();
p = rt.exec(myFileLocation);
Everything goes fine, but the behaviour of the .exe file is not the same. I mean when i run the commands
PrintWriter writer = new PrintWriter(p.getoutputStream());
writer.println("command");
the behaviour is not the same. What goes wrong.But to load the xml file I need to create a File objectIf this is true then you will not be able to load the XML file, since a jar entry is not a File object and cannot be represented as one.
However if you get rid of whatever it is that loads your XML file and replace it by more standard JAXP processing, you should be able to parse an InputStream that reads from the jar entry. You know how to get that so it should not be a problem. -
RegisterSchema errors for include and URN
Hello
I am trying to take advantage of XDB in processing XML documents. The XML Schema is provided by a third party and has several xsd files and a "master" file that imports the rest. I am having two problems with registerSchema.
1) For two of the namespaces, the XML types are defined in one xsd file and the elements in another. The file where the elements are defined INCLUDEs the file with the type definition. This seems like a not unreasonable thing to do. However, if I register the elements file first, I get the error that the included file is not an XDB schema file. If I register the included file first, then try to register the including file, I get the error that the namespace is already registered.
2) Two of the schemas have a URN for the schema URI, not a URL. I get the error Could Not Open urn:foo:bar:bah when I try to register that schema file.
Using includes and urns is certainly within spec. Why aren't these supported?
ThanksThis question is best suited for the {forum:id=34} forum. Make sure you look through the FAQs and pay attention to responses from mdrake or Marco Gralike dealing with registerSchema examples. I do know that you need to register the children (INCLUDE) files first. If you repost your question, include the commands you used to register the files.
-
How to move some xml element and its content to a new frame
Hi All,
How to move some xml element and its content to a new frame.Hi Chinnadk,
Sorry my code its comment some lines. Now only I check the forum thread, you just try one more time.
#target InDesign;
#include "/Program Files (x86)/Adobe/Adobe InDesign CS5.5/Scripts/XML Rules/glue code.jsx"
var myDoc = app.activeDocument;
//____________________ XML RULE SET
var myRuleSet = new Array (new margintag);
with(myDoc){
var elements = xmlElements;
__processRuleSet(elements.item(0), myRuleSet);
function margintag(){
this.name = "margintag";
//this.xpath = "//margintag[@type='mn2']";
this.xpath = "//margintag";
this.apply = function(myElement, myRuleProcessor){
with(myElement){
app.select(myElement);
try{
var myPrePara = app.selection[0].paragraphs[-1].parentTextFrames[0].paragraphs.previousItem(app.selection[0].paragraphs[-1]);
if(myPrePara.characters[-1].contents=="\r"){
myPrePara.characters[-1].remove();
var myTextframe = myElement.placeIntoInlineFrame(["7p9","6p"]);
myTextframe.appliedObjectStyle= myDoc.objectStyles.item("MN1");
myTextframe.fit(FitOptions.FRAME_TO_CONTENT);
myTextframe.parentStory.paragraphs.everyItem().appliedParagraphStyle = app.activeDocument.paragraphStyles.itemByName("MN1");
}catch(e){}
app.selection = null;
return true;
thx,
csm_phil -
Oracle XML parser and schema validation
Hi Forum,
I have problem parsing XML with validation against XML schema. I define location of schema (URL) in xml file and Oracle parser could not find the schema (xml file is correct - checked in other programs). When I point to xml schema directly from Java (using parser.setXMLSchema) before calling parser.parse, it works just fine. Where is the problem? Does oracle parser works correctly with XML Schema?
TIA,
AlexSAXParser saxParser=new SAXParser();
saxParser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
Specify a Schema to validate a XML document with, for the SAXParser.
saxParser.setXMLSchema(SchemaUrl);
DefaultHandler handler=new DefaultHandler();
saxParser.setErrorHandler(handler);
Parse the XML document to validate with the XML schema.
saxParser.parse(XmlDocumentUrl); -
XML structure and FCC parameters
Hi Experts,
Kindly help me with the XML structure and FCC parameters for the following sample of text file
I am new to Text Files and FCC.
=================================================================================
Header
" name of the company " ,1
" abc 2,10/01/1972",4
Line items
"ADFERT",KARNATAKA,CHIPS,G,45.560000,72.190000,100.983000,76.266000,J
"GHTJEN",KERALA,BANANAS,G,1.135000,0.714850,1,0.755000,J
Trailer
DDDDDDDDD,B
================================================================================
It is a CSV
Header 1st line , first field is Variable length and 2nd field is 1 char
Header 2nd line , first field is Variable length and 2nd field is date and last field is 1 char
Line items
first field fixed length 6 char but
2nd field can be of any length
3rd field can be of any length
4th field 1 char
5th field can be of any length
6th field can be of any length
7th field can be of any length
8th field can be of any length
9th field 1 char
and then the Trailer
Please help in the structure and content conversion parameters
also following questions :
a) I have to pick up this file and pass to a proxy in AbAP on target side , so do i just create a service interface and in ECC --> Sproxy and identify my SI and do a Create Proxy ? or is there anything else required ?
b) The Date in the header needs to be passed onto ECC as a parameter so in my XML structure in the data type do i include that as a field in the mapping ..Can any one please guide me to create the Data type structure for the above file ?
c) DO I NEED A MAPPING FOR THIS ?? THERE ARE NO CONVERSIONS required ? what are the IR and ID steps required
if it is a FILE to Proxy scenario with no mappings
Please help
thanks
DevHi Dev,
Full Data type is as follows
Sender_DT
order_recordset 0..1
order_header 0..1
header-1 0..1
date 0..1
order_Item 0..unbound
item-1 0..1
item-2 0..1
item-3 0..1
item-n 0..1
order_Trailer 0..1
trailer-1 0..1
trailer-2 0..1
trailer-n 0..1
> What about the File Content conversion parameters , can you help me with those
order_header.fieldNames : f1,date
order_header.fieldSeparator : <give the fiels separater , [if it is comma])
order_header.endSeparator : 'nl' (if it is new line characters)
order_item.fieldNames : i1,i2,.....
order_item.fieldSeparator : :
order_item.endSeparator : 'nl'
order_Trailer.fieldNames : t1,t2,.....
order_Trailer.fieldSeparator : :
order_Trailer.endSeparator : 'nl'
If any of the two structures (header, item or trailer) in the field name is same then we have to use the key field
Check this link
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417600)ID1157374550DB11273870171440820710End?blog=/pub/wlg/3228
> b) In FCC what will be the values for fieldnames ?
Check this link
https://wiki.sdn.sap.com/wiki/display/XI/XI_File_Content
Regards
Ramesh
Maybe you are looking for
-
Infinity won't work wirelessly with Ubuntu OS
I'm running Ubuntu Netbook Edition and upgraded my BT broadband to Infinity on 28.12.11, using the same HomeHub3 that worked perfectly well with the old Total service. It doesn't work, wirelessly. I can get an apparently strong connection, but its ag
-
How to find out the BI Publisher Version from the Excel output file
Hi, Can any one tell me How to find out the BI Publisher Version from the Excel output file generated using BI publisher.
-
My MBP refuses to read audio CD's created on Windows
I have about 30 - 40 Audio CD's that were created on a Windows machine. My MBP refuses to read these CD's and kicks them out after a 10 - 12 seconds of fumbling with them. The same CD can be read and imported using iTunes on a Windows machine. What s
-
Cannot get native resolution on my external monitor
System: - IBM Thinkpad T42p (display works intermittently) - Samsung Syncmaster 2333SW (1920x1080 native res.) - ATI Mobility Fire GL T2 (Driver vers. 6.14.10.6422) 1920x 1080 does not seem to be available through control panel for my external monito
-
PR Deletion flag set in LIMITs tab but not in Account Assignment tab
Can anyone help with this scenario? On the "Limits" tab of a PR, user enters multiple accounting lines. This results in table entries in both ESKL and EBKN Then, one ore more lines in the "Limits" tab get flagged for deletion but the cooresponding li