【发布时间】:2013-03-27 00:23:22
【问题描述】:
我有一个 XML 文件样本。现在我想用我拥有的 SQL 表数据生成一个原始 XML。
示例 XML 如下所示:
<?xml version="1.0"?>
<EmployeeSet xmlns=" http://www.example.com/Employee.xsd " xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DefaultDeptt xsi:nil="true"/>
<Report>
<Report Title="Yearly" Number="S678">
<Status>Current</Status>
<Deptt xsi:nil="true"/>
<Employee LastName="Name" FirstName="Simple" EMail="simple@organization.org" Login="simple"/>
<Location>Builiding 1</Location>
<SubmissionDate xsi:nil="true"/>
<ReportStartDate>2011-05-05</ReportStartDate>
<ReportFinishDate xsi:nil="true"/>
<ReportExpirationDate>2014-05-05</ReportExpirationDate>
<RenewalDate xsi:nil="true"/>
<Records>
<RecordsInfo Name="Paper">
<UsageRecords AnnualUse="5o0" Purpose="printing"/>
</RecordInfo>
</Record>
<Staff/>
</Report>
我从中获取数据的表具有以下结构:
- 报告标题
- 号码
- 状态
- 姓氏
- 名字
- 电子邮件
- login_id
- 位置
- 提交日期
- 开始日期
- Finsih_date
- 续订日期
- 姓名
- 每年使用一次
- 目的
我试过了,我得到了关注:
<EmployeeSet xmlns="http://www.example.com/Employee.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DefaultDeptt xsi:nil="true"></DefaultDeptt>
<report_title>TESTINGNEW</report_TITLE>
<NUMBER>AC10006</NUMBER>
<STATUS>Approved</STATUS>
<LAST_NAME>XYZ</LAST_NAME>
<FIRST_NAME>ABC</PI_FIRST_NAME>
<EMAIL>ABC.XYZ@gmail.com</EMAIL>
<LOGIN_ID>ABCXYZ</LOGIN_ID>
<LOCATION> </ LOCATION>
<SUBMISSION_DATE>2013-03-25</SUBMISSION_DATE> <START_DATE>2013-03-25</START_DATE>
<FINISH_DATE>2013-03-25</FINISH_DATE>
<RENEWAL_DATE>2014-01-9</RENEWAL_DATE>
<NAME>PAPER</NAME>
<ANNUAL_USE>670</ANNUAL_USE>
<PURPOSE> PRINTING</PURPOSE>
</EmployeeSet>
【问题讨论】:
-
我正在尝试使用以下查询,但结果不一样:
select XMLElement("EmployeeSet",XMLAttributes('http://www.abc.com.Employee.xsd' as "xmlns",'http://www.w3.org/2001/XMLSchema' as "xmlns:xsd", 'http://www.w3.org/2001/XMLSchema-instance' as "xmlns:xsi"), XMLElement("DefaultDeptt",XMLAttributes('true' as "xsi:nil")), XMLForest(title, number, status, last_name, first_name, email, login_id, location, submission_date, startdate, finishdate, renewaldate, name, annual_use, purpose)) as "XML" from xyz.emp_temp; -
我是使用 oracle 的 XML 新手。从教程中我学到的只是这些命令。
-
你能发送一个包含 2 条表记录的示例 xml 文件吗?
-
我已将我的 xml 输出添加到问题中。请看一下。
标签: plsql oracle10g xml-serialization xsd plsqldeveloper