cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT - Get XML from other XML

Former Member
0 Kudos

Hi All !!!

Just a question. I need to get an XML from other XML.

From this one:

#Number 1


<?xml version="1.0" encoding="UTF-8"?>

<ns0:JDBC_SELECT xmlns:ns0="http://namespace.com/nt">

          <row>

                    <KEY>k</KEY>

                    <QUEUE_TYPE>k</QUEUE_TYPE>

                    <EVENT_STATUS>k</EVENT_STATUS>

                    <EVENT_TYPE>k</EVENT_TYPE>

                    <CONTENT>

                              <event version="1.0" type="New" timestamp="20130129T15:59:13.850Z" target="SAP" source="NBA" reference="0000000000" id="12">

                                        <newworkpackagerequestevent>

                                                  <workorderid>1</workorderid>

                                                  <personnelid>se_a</personnelid>

                                                  <requesttimestamp>20130129T15:59:13.850Z</requesttimestamp>

                                                  <newnotificationrequest>kkkkk</newnotificationrequest>

                                                  <type>Z2</type>

                                                  <requirementcode>DS0</requirementcode>

                                                  <mainworkcentre>0102</mainworkcentre>

                                                  <plannergroup>L00</plannergroup>

                                                  <functionallocationid>1005</functionallocationid>

                                                  <shorttext>DETAILED SURVEY PER WWMD</shorttext>

                                                  <longtext>DETAILED SURVEY PER WWMD</longtext>

                                                  <personnelrespid>12157</personnelrespid>

                                                  <costcentre>3600</costcentre>

                                                  <newworkorderrequest>

                                                            <type>ZPM2</type>

                                                  </newworkorderrequest>

                                        </newworkpackagerequestevent>

                              </event>

                    </CONTENT>

          </row>

</ns0:JDBC_SELECT>

I need to get all from <CONTENT> node.

It should be:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:CONTENT xmlns:ns0="http://namespace.com/nt">

          <event version="1.0" type="New" timestamp="20130129T15:59:13.850Z" target="SAP" source="NBA" reference="0000000000" id="12">

                    <newworkpackagerequestevent>

                              <workorderid>1</workorderid>

                              <personnelid>se_a</personnelid>

                              <requesttimestamp>20130129T15:59:13.850Z</requesttimestamp>

                              <newnotificationrequest>kkkkk</newnotificationrequest>

                              <type>Z2</type>

                              <requirementcode>DS0</requirementcode>

                              <mainworkcentre>0102</mainworkcentre>

                              <plannergroup>L00</plannergroup>

                              <functionallocationid>1005</functionallocationid>

                              <shorttext>DETAILED SURVEY PER WWMD</shorttext>

                              <longtext>DETAILED Nightline Increase</longtext>

                              <personnelrespid>12157</personnelrespid>

                              <costcentre>3600</costcentre>

                              <newworkorderrequest>

                                        <type>ZPM2</type>

                              </newworkorderrequest>

                    </newworkpackagerequestevent>

          </event>

</ns0:CONTENT>

But, What I am getting is this (in red):

<?xml version="1.0" encoding="UTF-8"?>1 -2 -3 -4<ns0:CONTENT xmlns:ns0="http://namespace.com/nt">

          <event version="1.0" type="New" timestamp="20130129T15:59:13.850Z" target="SAP" source="NBA" reference="0000000000" id="12">

                    <newworkpackagerequestevent>

                              <workorderid>1</workorderid>

                              <personnelid>se_a</personnelid>

                              <requesttimestamp>20130129T15:59:13.850Z</requesttimestamp>

                              <newnotificationrequest>kkkkk</newnotificationrequest>

                              <type>Z2</type>

                              <requirementcode>DS0</requirementcode>

                              <mainworkcentre>0102</mainworkcentre>

                              <plannergroup>L00</plannergroup>

                              <functionallocationid>1005</functionallocationid>

                              <shorttext>DETAILED SURVEY PER WWMD</shorttext>

                              <longtext>DETAILED SURVEY PER WWMD</longtext>

                              <personnelrespid>12157</personnelrespid>

                              <costcentre>3600</costcentre>

                              <newworkorderrequest>

                                        <type>ZPM2</type>

                              </newworkorderrequest>

                    </newworkpackagerequestevent>

          </event>

</ns0:CONTENT>

Using this XSLT

<?xml version="1.0" encoding="UTF-8"?>

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

          <xsl:template match="event">

    </xsl:template>

          <xsl:output method="xml" indent="yes"/>

          <xsl:template match="CONTENT">

                    <ns0:CONTENT xmlns:ns0="http://namespace.com/nt">

                              <xsl:copy-of select="event"/>

                    </ns0:CONTENT>

          </xsl:template>

</xsl:transform>

Please, try on http://xslttest.appspot.com/

Could anyone tell me which XSLT I should get?

Thanks!!!

Cerbero

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Cerbero,

Please try this:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >

                   <xsl:output method="xml" indent="yes"/>

          <xsl:template match="/">

                                             <ns0:CONTENT xmlns:ns0="http://namespace.com/nt">

                              <xsl:copy-of select="//event"/>

                    </ns0:CONTENT>

          </xsl:template>

</xsl:transform>

Regards,

Beena.

Former Member
0 Kudos

Thanks you !!!!

Former Member
0 Kudos

Hi Beena

They have changed the especification.

I have this XML now:

<?xml version="1.0" encoding="UTF-8" ?>

<ns:JDBC_SELECT xmlns:ns="http://namespace.com/nt">

<row>

  <KEY>19</KEY>

  <QUEUE_TYPE>2</QUEUE_TYPE>

  <EVENT_STATUS>0</EVENT_STATUS>

  <EVENT_TYPE>New Work Package Request</EVENT_TYPE>

  <CONTENT><?xml version="1.0" encoding="utf-8" standalone="yes"?><event xmlns:ns="http://namespace.com/nt" reference="0000000000" source="NBA" target="SAP" timestamp="2013-02-04T14:32:01.836+00:00" type="New Work Package Request" version="1.0" id="19"><new-work-package-request-event><work-order-id>11</work-order-id><personnel-id>ra_a</personnel-id><request-timestamp>2013-02-04T14:32:01.836+00:00</request-timestamp><new-notification-request><type>Z2</type><requirement-code>RI0D</requirement-code><main-work-centre>0102</main-work-centre><planner-group>L00</planner-group><functional-location-id>1024</functional-location-id><short-text>SET UP/REMOVE ISOLATION RUN</short-text><long-text>SET UP/REMOVE ISOLATION RUN, 1024, NORTON FOXLEY (PRV) NORTON FOXLEY Nightline Increase: (l/h)</long-text><personnel-resp-id>12157</personnel-resp-id><cost-centre>3600</cost-centre></new-notification-request><new-work-order-request><type>ZPM2</type></new-work-order-request></new-work-package-request-event></event></CONTENT>

  </row>

</ns:JDBC_SELECT>

I need to extract the XML inside <CONTENT> field.

Could you help me please or some else who read this?

Thanks!

gagandeep_batra
Active Contributor
0 Kudos

Hi

did you try like this:

<xsl:copy-of select="//CONTENT"/>

Regards

Gagan

Former Member
0 Kudos

Yes, but not luck.

Please, try on http://xslttest.appspot.com/

Thanks

Answers (1)

Answers (1)

Former Member
0 Kudos

I think I need to escape caracteres.

Ideas?

Former Member
0 Kudos

Solved with JavaMapping.