[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Adding element to xml snippet using xslt
Joris Gillis wrote:
Tempore 22:05:27, die 02/21/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Nishi Bhonsle <nishi.bhonsle@xxxxxxxxxx>: Hi: The started element is at the same level as the server element and not a part of it. I am providing a more complete snippet below of the orginal xml file say FileA -- <abc:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://oracle.com/ xmlns/abcst/configurationconfiguration.xsd" locale="en" webcache="false" rmi="true"> <started status="true"></started> <server></server> <servlet autoRetryAfter="5" charting="true" chartingTimeout="60" queryRefreshPeriod="6"</servlet>> .... </abc:configuration> This FileA needs to be merged with the FileB using xslt to get a final resultant file FileC. FileB contains -- <abc:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://oracle.com/ xmlns/abcst/configurationconfiguration.xsd" locale="en" webcache="false" rmi="true" metadata="true" useMgmt="true"> <drillOutDir></drillOutDir> <started status="true">This application was stopped.</started> <server></server> <servlet autoRetryAfter="5" charting="true" chartingTimeout="60" queryRefreshPeriod="6"</servlet>> .... </abc:configuration> FileC should contain should contain all elements of A and the new elements of B with the common ones being merged-- FileC should contain -- <abc:configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://oracle.com/ xmlns/abcst/configurationconfiguration.xsd" locale="en" webcache="false" rmi="true" metadata="true" useMgmt="true"> <drillOutDir></drillOutDir> <started status="true">This application was stopped.</started> <server></server> <servlet autoRetryAfter="5" charting="true" chartingTimeout="60" queryRefreshPeriod="6"</servlet>> .... </abc:configuration> Currently, everything gets copied correctly to FileC except the fact that the "started" element is copied/merged as an empty element such as <started></started>. If I take out the "started" element from the "server" node and place it outside, it does not even showup in the final merged output. <xsl:template match="abc:configuration"> <xsl:copy> <xsl:copy-of select="@*[local-name() != 'rmi' and local-name() != 'locale']"/> <xsl:attribute name="useMgmt"> <xsl:text>true</xsl:text></xsl:attribute> <xsl:attribute name="metadata"><xsl:text>true</xsl:text></xsl:attribute> <xsl:apply-templates> <xsl:sort select="boolean(self::server)" order="descending"/> </xsl:apply-templates> </xsl:copy> <xsl:text></xsl:text> </xsl:template> <xsl:template match="server"> <xsl:element name="drillOutDir"> <xsl:value-of select="abc:configuration/drillOutDir"/ </xsl:element> <xsl:element name="started"> <xsl:copy-of select="@status[. = 'true' ]"/> <xsl:value-of select="../abc:configuration/started"/> </xsl:element> </xsl:template> <xsl:template match="abc:configuration/started"> <xsl:apply-templates/> </xsl:template> Please help. Thanks.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|