我有一个xml生成查询,如下所示
select
XMLElement( "Persons" ,
(select XMLAgg( XMLElement("Person" ,
XmlElement( "FirstName",First_name) ,
XmlElement( "SecondName",Second_name) ,
XMLElement("LastName", last_name)
).transform(xmltype('<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>')))
FROM np_persons )
)
AS "RESULT"
From dual
它正在成功生成数据,如下所示
<Persons>
<Person>
<FirstName>Jack</FirstName>
<SecondName/>
<LastName>Stephen</LastName>
</Person>
<Person>
<FirstName>Jack</FirstName>
<SecondName>M</SecondName>
<LastName>Stephen</LastName>
</Person>
</Persons>
此处为第一条记录SecondName为null,因此标记为<SecondName/>
我也希望它为<SecondName></SecondName>
怎么能达到同样的目的呢?