Skip to Content

requirement in xslt mapping

Hi All,

i have posted different questions for my requirement, now i am placing all questions in this thread.

below is the my input xml code

<?xml version="1.0" encoding="UTF-8"?> <EPCISDocument xmlns:ns1="http://apse.com" schemaVersion="" creationDate=""><EPCISHeader><StandardBusinessDocumentHeader><HeaderVersion></HeaderVersion><Sender><Identifier Authority=""></Identifier><ContactInformation><Contact></Contact><EmailAddress></EmailAddress><FaxNumber></FaxNumber><TelephoneNumber></TelephoneNumber><ContactTypeIdentifier></ContactTypeIdentifier></ContactInformation></Sender><Receiver><Identifier Authority=""></Identifier><ContactInformation><Contact></Contact><EmailAddress></EmailAddress><FaxNumber></FaxNumber><TelephoneNumber></TelephoneNumber><ContactTypeIdentifier></ContactTypeIdentifier></ContactInformation></Receiver><Manifest><NumberOfItems></NumberOfItems><ManifestItem><MimeTypeQualifierCode></MimeTypeQualifierCode><UniformResourceIdentifier></UniformResourceIdentifier><Description></Description><LanguageCode></LanguageCode></ManifestItem></Manifest><BusinessScope><Scope><BusinessService><BusinessServiceName></BusinessServiceName><ServiceTransaction TypeOfServiceTransaction="" IsNonRepudiationRequired="" IsAuthenticationRequired="" IsNonRepudiationOfReceiptRequired="" IsIntegrityCheckRequired="" IsApplicationErrorResponseRequired="" TimeToAcknowledgeReceipt="" TimeToAcknowledgeAcceptance="" TimeToPerform=""></ServiceTransaction></BusinessService><CorrelationInformation><RequestingDocumentCreationDateTime></RequestingDocumentCreationDateTime><RequestingDocumentInstanceIdentifier></RequestingDocumentInstanceIdentifier><ExpectedResponseDateTime></ExpectedResponseDateTime></CorrelationInformation></Scope></BusinessScope></StandardBusinessDocumentHeader></EPCISHeader><EPCISBody><EventList><ObjectEvent><eventTime></eventTime><recordTime></recordTime><eventTimeZoneOffset></eventTimeZoneOffset><epcList><epc type=""></epc></epcList><action></action><bizStep></bizStep><disposition></disposition><readPoint><id></id></readPoint><bizLocation><id></id></bizLocation><bizTransactionList><bizTransaction type=""></bizTransaction></bizTransactionList><GskEpcExtension><manufacturingDate>1234</manufacturingDate></GskEpcExtension></ObjectEvent></EventList></EPCISBody></EPCISDocument>

i wrote some xsl code to add gsk prefix for GskEpcExtension node and it's elements.

below is the xsl code

http://www.w3.org/1999/XSL/Transform" xmlns:gsk=" http://apse.com"> http://apse.com">

but after this xsl output that gsk prefix is adding for every elements,which is not correct.i need to add only for gskepcextension node in the above payload.

In same way for EPCISheader also i need to add prefix as sbdh: for each element.

EPCISbody should pass as it is with out prefixes.

Please suggest me how can i modify my xslt code to achieve above requirement.

here is the output which i got after xsl

<?xml version="1.0" encoding="UTF-8" ?> - http://apse.com" schemaVersion="" creationDate=""> - - - - - - - - - - - - - - - - - - - - 1234

i referred lot of threads, i am not getting exact answer.. please help on this.

Regards,

Janardhan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jan 06, 2017 at 01:38 PM

    Hello Janardhan,

    Hopefully below code can give you the expected result.

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:gsk="http://apse.com">
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
     <xsl:template match="EPCISDocument/EPCISBody/EventList/ObjectEvent/GskEpcExtension">
      <xsl:element name="gsk:{local-name()}" namespace="http://apse.com">
        <xsl:apply-templates />
      </xsl:element>
     </xsl:template>
    </xsl:stylesheet>

    Don't forget to reward points if it works... :P

    As ever,

    Nagesh

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 04, 2017 at 11:54 AM
    below is the xsl code for the same
    
    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:gsk="http://apse.com">
     
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
    
     <xsl:template match="*">
      <xsl:element name="gsk:{name()}" namespace="http://apse.com">
        <xsl:copy-of select="namespace::*"/>
        <xsl:apply-templates select="node()|@*"/>
      </xsl:element>
     </xsl:template>
    </xsl:stylesheet>
    
    Add comment
    10|10000 characters needed characters exceeded

  • Jan 04, 2017 at 11:55 AM

    the output of the code is

      <?xml version="1.0" encoding="UTF-8" ?> 
    - <gsk:EPCISDocument xmlns:gsk="http://apse.com" schemaVersion="" creationDate="">
    - <gsk:EPCISHeader>
    - <gsk:StandardBusinessDocumentHeader>
      <gsk:HeaderVersion /> 
    - <gsk:Sender>
      <gsk:Identifier Authority="" /> 
    - <gsk:ContactInformation>
      <gsk:Contact /> 
      <gsk:EmailAddress /> 
      <gsk:FaxNumber /> 
      <gsk:TelephoneNumber /> 
      <gsk:ContactTypeIdentifier /> 
      </gsk:ContactInformation>
      </gsk:Sender>
    - <gsk:Receiver>
      <gsk:Identifier Authority="" /> 
    - <gsk:ContactInformation>
      <gsk:Contact /> 
      <gsk:EmailAddress /> 
      <gsk:FaxNumber /> 
      <gsk:TelephoneNumber /> 
      <gsk:ContactTypeIdentifier /> 
      </gsk:ContactInformation>
      </gsk:Receiver>
    - <gsk:Manifest>
      <gsk:NumberOfItems /> 
    - <gsk:ManifestItem>
      <gsk:MimeTypeQualifierCode /> 
      <gsk:UniformResourceIdentifier /> 
      <gsk:Description /> 
      <gsk:LanguageCode /> 
      </gsk:ManifestItem>
      </gsk:Manifest>
    - <gsk:BusinessScope>
    - <gsk:Scope>
    - <gsk:BusinessService>
      <gsk:BusinessServiceName /> 
      <gsk:ServiceTransaction TypeOfServiceTransaction="" IsNonRepudiationRequired="" IsAuthenticationRequired="" IsNonRepudiationOfReceiptRequired="" IsIntegrityCheckRequired="" IsApplicationErrorResponseRequired="" TimeToAcknowledgeReceipt="" TimeToAcknowledgeAcceptance="" TimeToPerform="" /> 
      </gsk:BusinessService>
    - <gsk:CorrelationInformation>
      <gsk:RequestingDocumentCreationDateTime /> 
      <gsk:RequestingDocumentInstanceIdentifier /> 
      <gsk:ExpectedResponseDateTime /> 
      </gsk:CorrelationInformation>
      </gsk:Scope>
      </gsk:BusinessScope>
      </gsk:StandardBusinessDocumentHeader>
      </gsk:EPCISHeader>
    - <gsk:EPCISBody>
    - <gsk:EventList>
    - <gsk:ObjectEvent>
      <gsk:eventTime /> 
      <gsk:recordTime /> 
      <gsk:eventTimeZoneOffset /> 
    - <gsk:epcList>
      <gsk:epc type="" /> 
      </gsk:epcList>
      <gsk:action /> 
      <gsk:bizStep /> 
      <gsk:disposition /> 
    - <gsk:readPoint>
      <gsk:id /> 
      </gsk:readPoint>
    - <gsk:bizLocation>
      <gsk:id /> 
      </gsk:bizLocation>
    - <gsk:bizTransactionList>
      <gsk:bizTransaction type="" /> 
      </gsk:bizTransactionList>
    - <gsk:GskEpcExtension>
      <gsk:manufacturingDate>1234</gsk:manufacturingDate> 
      </gsk:GskEpcExtension>
      </gsk:ObjectEvent>
      </gsk:EventList>
      </gsk:EPCISBody>
      </gsk:EPCISDocument>
    
    Add comment
    10|10000 characters needed characters exceeded