0 users online. Create an account or sign in to join them.Users

Search

Hi. I want to comment the xml file into json using xsl. I tried many ways but I am able to do.

XML:

<?xml version="1.0" encoding="UTF-8"?>
<manifests xmlns="http://www.moveit.com.au/schema/data.xsd">
  <manifest ref="false">
    <manifestNumber>20161214141153978</manifestNumber>
    <despatchDate>2016-10-04T23:30:00</despatchDate>
    <actualDespatchDate>2016-12-14T14:11:54</actualDespatchDate>
    <shipper>
      <participant ref="true">
        <type>shipper</type>
        <licenseType>ACCESS</licenseType>
        <businessName>PMP LIMITED</businessName>
        <tradingName>PMP LIMITED</tradingName>
      </participant>
    </shipper>
    <pickUpAddress>
      <address externalId="BL" category="" ref="true">
        <owner>
          <participant ref="true">
            <businessName>PMP LIMITED</businessName>
          </participant>
        </owner>
        <country id="AU" name="Australia" countryCode="AU" />
        <line1>PMP Print - Bibra Lake</line1>
        <line2>51 Miguel Road</line2>
        <town>BIBRA LAKE</town>
        <state>WA</state>
        <postcode>6163</postcode>
        <unloadSequence>0</unloadSequence>
        <addressReferenceId>BL</addressReferenceId>
        <preferredJourneyId />
        <specialInstructions />
        <deliveryCloseTime />
        <deliveryOpenTime />
      </address>
    </pickUpAddress>
    <deliveryAddress>
      <address copyOf="Big W Kingsway Cnr Wanneroo Road &amp;" category="" ref="true">
        <owner>
          <participant ref="true">
            <businessName>PMP LIMITED</businessName>
          </participant>
        </owner>
        <country id="AU" name="Australia" countryCode="AU" />
        <line1>Big W Kingsway</line1>
        <line2>Cnr Wanneroo Road &amp;</line2>
        <line3>Hepburn Avenue</line3>
        <line4 />
        <town>LANDSDALE</town>
        <state>WA</state>
        <postcode>6065</postcode>
        <contactName />
        <contactPhone />
        <customerGroup />
        <addressReferenceId>Big W Kingsway Cnr Wanneroo Road &amp;</addressReferenceId>
        <specialInstructions />
        <deliveryCloseTime />
        <deliveryOpenTime />
      </address>
    </deliveryAddress>
    <rate>0</rate>
    <totalLineItemContainers>2</totalLineItemContainers>
    <weight>10</weight>
    <volume>0</volume>
    <extensions />
    <consignments>
      <consignment ref="true">
        <owner>
          <participant ref="true">
            <type>carrier</type>
            <licenseType>ACCESS</licenseType>
            <businessNumber>9998888999</businessNumber>
            <businessName>PMP CLIENT PICKUP</businessName>
            <tradingName>PMP CLIENT PICKUP</tradingName>
          </participant>
        </owner>
        <consignmentNumber>BLCP000653</consignmentNumber>
        <freightStateName>In Transit</freightStateName>
        <shipper>
          <participant ref="true">
            <type>shipper</type>
            <licenseType>ACCESS</licenseType>
            <businessName>PMP LIMITED</businessName>
            <tradingName>PMP LIMITED</tradingName>
          </participant>
        </shipper>
        <id>3377699720845488</id>
        <despatchDate>2016-10-04</despatchDate>
        <actualDespatchDate>2016-12-14T14:11:54</actualDespatchDate>
        <expectedDeliveryDate>2016-10-05</expectedDeliveryDate>
        <creationDate>2016-10-05</creationDate>
        <pickUpAddress>
          <address copyOf="BL" category="" ref="true">
            <owner>
              <participant ref="true">
                <businessName>PMP LIMITED</businessName>
              </participant>
            </owner>
            <country id="AU" name="Australia" countryCode="AU" />
            <line1>PMP Print - Bibra Lake</line1>
            <line2>51 Miguel Road</line2>
            <town>BIBRA LAKE</town>
            <state>WA</state>
            <postcode>6163</postcode>
            <unloadSequence>0</unloadSequence>
            <addressReferenceId>BL</addressReferenceId>
            <preferredJourneyId />
            <specialInstructions />
            <deliveryCloseTime />
            <deliveryOpenTime />
          </address>
        </pickUpAddress>
        <pickupZoneExternalID>/PMP_CLIENT_PICKUP_ZONES/AUS</pickupZoneExternalID>
        <deliveryAddress>
          <address copyOf="Big W Kingsway Cnr Wanneroo Road &amp;" category="" ref="true">
            <owner>
              <participant ref="true">
                <businessName>PMP LIMITED</businessName>
              </participant>
            </owner>
            <country id="AU" name="Australia" countryCode="AU" />
            <line1>Big W Kingsway</line1>
            <line2>Cnr Wanneroo Road &amp;</line2>
            <line3>Hepburn Avenue</line3>
            <line4 />
            <town>LANDSDALE</town>
            <state>WA</state>
            <postcode>6065</postcode>
            <contactName />
            <contactPhone />
            <customerGroup />
            <addressReferenceId>Big W Kingsway Cnr Wanneroo Road &amp;</addressReferenceId>
            <specialInstructions />
            <deliveryCloseTime />
            <deliveryOpenTime />
          </address>
        </deliveryAddress>
        <deliveryZoneExternalID>/PMP_CLIENT_PICKUP_ZONES/AUS</deliveryZoneExternalID>
        <chargeAccount chargeParty="shipper" />
        <returnConsignment>false</returnConsignment>
        <service name="ROAD EXPRESS" workingDaysOnly="false" ref="true">
          <carrier>
            <participant ref="true">
              <businessName>PMP CLIENT PICKUP</businessName>
            </participant>
          </carrier>
        </service>
        <journey name="PMP CLIENT PICKUP ROAD EXPRESS" ref="true">
          <owner>
            <participant ref="true">
              <businessName>PMP CLIENT PICKUP</businessName>
            </participant>
          </owner>
          <legService ref="true">
            <owner>
              <participant ref="true">
                <businessName>PMP CLIENT PICKUP</businessName>
              </participant>
            </owner>
            <leg name="ROAD EXPRESS" ref="true">
              <owner>
                <participant ref="true">
                  <businessName>PMP CLIENT PICKUP</businessName>
                </participant>
              </owner>
            </leg>
            <service name="ROAD EXPRESS" workingDaysOnly="false" ref="true">
              <carrier>
                <participant ref="true">
                  <businessName>PMP CLIENT PICKUP</businessName>
                </participant>
              </carrier>
            </service>
          </legService>
        </journey>
        <specialInstructions />
        <rate>0</rate>
        <rateIncSurcharge>0</rateIncSurcharge>
        <rateWithoutMargin>0</rateWithoutMargin>
        <rateWithoutMarginIncSurcharge>0</rateWithoutMarginIncSurcharge>
        <weight>10</weight>
        <volume>0</volume>
        <extensions />
        <lineItems>
          <lineItem description="300" costCode="WA Store">
            <id>16888498607755132</id>
            <volume>0</volume>
            <weight>10</weight>
            <extensions>
              <unconsolidatedLineItemRateExtension>
                <consolidatedBuyRate>0.00</consolidatedBuyRate>
                <consolidatedSellRate>0.00</consolidatedSellRate>
                <unConsolidatedBuyRate>0.00</unConsolidatedBuyRate>
                <unConsolidatedSellRate>0.00</unConsolidatedSellRate>
              </unconsolidatedLineItemRateExtension>
            </extensions>
            <container unit="Carton" amount="2" weight="5" length="0" width="0" height="0" volume="0" uomRank="1" labelCopies="1">
              <references stringValue="MKBIGW1623 - Big W PEFC 24pp os 13.10">
                <reference>MKBIGW1623 - Big W PEFC 24pp os 13.10</reference>
              </references>
            </container>
            <totalLabels>0</totalLabels>
          </lineItem>
        </lineItems>
        <silentMode>false</silentMode>
        <forceDespatchToCarrier />
        <autoDespatch>false</autoDespatch>
        <autoDeliver>false</autoDeliver>
        <actualLongDespatchTime>1481686914328</actualLongDespatchTime>
        <useSlaveDeliveryAddress>false</useSlaveDeliveryAddress>
      </consignment>
    </consignments>
    <silentMode>false</silentMode>
    <autoDespatch>false</autoDespatch>
    <autoDeliver>false</autoDeliver>
  </manifest>
</manifests>

XSL:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    exclude-result-prefixes="data">
    <!-- Import common templates -->
    <xsl:output method="xml" indent="yes" />
    <!-- Root template -->
    <xsl:template match="/">
            {
            "manifest":
            <xsl:for-each select="manifests">
                <xsl:for-each select="manifest">
                {
                    "consignments":
                    {
                       "consignment":
                             <xsl:for-each select="consignments">
                                 <xsl:for-each select="consignment">
                            {
                                 "owner":
                                     {
                                         "participant":
                                             <xsl:for-each select="owner">
                                                 <xsl:for-each select="participant">
                                                  {
                                                     "type":"<xsl:value-of select="type" />",
                                                     "licenseType":"<xsl:value-of select="licenseType" />",
                                                     "businessNumber":"<xsl:value-of select="businessNumber" />",
                                                     "businessName":"<xsl:value-of select="businessName" />",
                                                     "tradingName":"<xsl:value-of select="tradingName" />"
                                                  }
                                                 </xsl:for-each>
                                             </xsl:for-each>
                                     },
                                     {
                                        "consignmentNumber":"<xsl:value-of select="consignmentNumber" />"
                                     },
                                     {
                                         "freightStateName":"<xsl:value-of select="freightStateName" />"
                                     },
                                     {
                                         "shipper":
                                             {
                                                 "participant":
                                                         <xsl:for-each select="shipper">
                                                             <xsl:for-each select="participant">
                                                                 {
                                                                     "type":"<xsl:value-of select="type" />", 
                                                                     "licenseType":"<xsl:value-of select="licenseType" />",
                                                                     "businessName":"<xsl:value-of select="businessName" />",
                                                                     "tradingName":"<xsl:value-of select="tradingName" />"
                                                                 }
                                                             </xsl:for-each>
                                                         </xsl:for-each>
                                              }
                                     },
                                     {
                                         "id":"<xsl:value-of select="id" />"
                                     },
                                     {
                                         "despatchDate":"<xsl:value-of select="despatchDate" />"
                                     },
                                     {
                                         "actualDespatchDate":"<xsl:value-of select="actualDespatchDate" />"
                                     },
                                     {
                                         "expectedDeliveryDate":"<xsl:value-of select="expectedDeliveryDate" />"
                                     },
                                     {
                                         "creationDate":"<xsl:value-of select="creationDate" />"
                                     },
                                     {
                                         "pickUpAddress":
                                        {     
                                             "address":  
                                            {    <xsl:for-each select="pickUpAddress">
                                                             <xsl:for-each select="address">

                                                 "owner":
                                                 {
                                                     "participant":
                                                         <xsl:for-each select="owner">
                                                             <xsl:for-each select="participant">
                                                             {
                                                                 "businessName":"<xsl:value-of select="businessName" />"
                                                             }
                                                             </xsl:for-each>
                                                         </xsl:for-each>
                                                 },
                                                 {
                                                     "line1":"<xsl:value-of select="line1"/>"
                                                 },
                                                 {
                                                     "line2":"<xsl:value-of select="line2"/>"
                                                 },
                                                 {
                                                     "town":"<xsl:value-of select="town" />"
                                                 },
                                                 {
                                                     "state":"<xsl:value-of select="state" />"
                                                 },
                                                 {
                                                     "postcode":"<xsl:value-of select="postcode" />"
                                                 },
                                                 {
                                                     "unloadSequence":"<xsl:value-of select="unloadSequence" />"
                                                 },
                                                 {
                                                     "addressReferenceId":"<xsl:value-of select="addressReferenceId" />"
                                                 },
                                                 {
                                                     "preferredJourneyId":"<xsl:value-of select="preferredJourneyId" />"
                                                 },
                                                 {
                                                     "specialInstructions":"<xsl:value-of select="specialInstructions" />"
                                                 },
                                                 {
                                                     "deliveryCloseTime":"<xsl:value-of select="deliveryCloseTime" />"
                                                 },
                                                 {
                                                     "deliveryOpenTime":"<xsl:value-of select="deliveryOpenTime" />"
                                                 }
                                                 </xsl:for-each>
                                                         </xsl:for-each>
                                            }

                                        }

                                    },
                                    {
                                      "pickupZoneExternalID":"<xsl:value-of select="pickupZoneExternalID" />"
                                    },
                                    {
                                         "deliveryAddress":
                                        {     
                                             "address":  
                                            {    <xsl:for-each select="deliveryAddress">
                                                             <xsl:for-each select="address">

                                                 "owner":
                                                 {
                                                     "participant":
                                                         <xsl:for-each select="owner">
                                                             <xsl:for-each select="participant">
                                                             {
                                                                 "businessName":"<xsl:value-of select="businessName" />"
                                                             }
                                                             </xsl:for-each>
                                                         </xsl:for-each>
                                                 },
                                                 {
                                                     "line1":"<xsl:value-of select="line1"/>"
                                                 },
                                                 {
                                                     "line2":"<xsl:value-of select="line2"/>"
                                                 },
                                                 {
                                                     "line3":"<xsl:value-of select="line3"/>"
                                                 },
                                                 {
                                                     "line4":"<xsl:value-of select="line4"/>"
                                                 },
                                                 {
                                                     "town":"<xsl:value-of select="town" />"
                                                 },
                                                 {
                                                     "state":"<xsl:value-of select="state" />"
                                                 },
                                                 {
                                                     "postcode":"<xsl:value-of select="postcode" />"
                                                 },
                                                 {
                                                     "contactName":"<xsl:value-of select="contactName" />"
                                                 },
                                                 {
                                                     "contactPhone":"<xsl:value-of select="contactPhone" />"
                                                 },
                                                 {
                                                     "customerGroup":"<xsl:value-of select="customerGroup" />"
                                                 },
                                                 {
                                                     "addressReferenceId":"<xsl:value-of select="addressReferenceId" />"
                                                 },
                                                 {
                                                     "specialInstructions":"<xsl:value-of select="specialInstructions" />"
                                                 },
                                                 {
                                                     "deliveryCloseTime":"<xsl:value-of select="deliveryCloseTime" />"
                                                 },
                                                 {
                                                     "deliveryOpenTime":"<xsl:value-of select="deliveryOpenTime" />"
                                                 }
                                                 </xsl:for-each>
                                                         </xsl:for-each>
                                            }     
                                        }
                                    },
                                    {
                                       "deliveryZoneExternalID":<xsl:value-of select="deliveryZoneExternalID" />
                                    },
                                    {
                                       "chargeAccount":<xsl:value-of select="chargeAccount" />
                                    },
                                    {
                                       "returnConsignment":<xsl:value-of select="returnConsignment" />
                                    },
                                    {
                                       "service":
                                       {
                                          "carrier";
                                          {
                                             "participant":
                                                 <xsl:for-each select="service">
                                                     <xsl:for-each select="carrier">
                                                         <xsl:for-each select="participant">
                                                         {
                                                             "businessName":"<xsl:value-of select="businessName" />" 
                                                         }
                                                 </xsl:for-each>
                                                     </xsl:for-each>
                                                         </xsl:for-each>
                                          }
                                       }
                                    },
                                    {
                                        "journey":
                                             <xsl:for-each select="journey">
                                                 {
                                                     "owner": 
                                                     {
                                                         "participant":
                                                             <xsl:for-each select="owner">
                                                                 <xsl:for-each select="participant">
                                                                 {
                                                                     "businessName":"<xsl:value-of select="businessName" />" 
                                                                 }
                                                                 </xsl:for-each>
                                                             </xsl:for-each>      
                                                     },
                                                     {
                                                       "legService":
                                                       <xsl:for-each select="legService">
                                                       {
                                                         "owner": 
                                                             {
                                                                 "participant":
                                                                     <xsl:for-each select="owner">
                                                                         <xsl:for-each select="participant">
                                                                     {
                                                                         "businessName":"<xsl:value-of select="businessName" />" 
                                                                     }
                                                                         </xsl:for-each>
                                                                     </xsl:for-each>      
                                                             },
                                                             {
                                                                "leg":
                                                                    {
                                                                         "owner": 
                                                                             {
                                                                                 "participant":
                                                                                 <xsl:for-each select="leg">
                                                                                     <xsl:for-each select="owner">
                                                                                         <xsl:for-each select="participant">
                                                                                                 {
                                                                                                      "businessName":"<xsl:value-of select="businessName" />" 
                                                                                                 }
                                                                                         </xsl:for-each>
                                                                                     </xsl:for-each>
                                                                                 </xsl:for-each>     
                                                                              }
                                                                    }
                                                             },
                                                             {
                                                                "service":
                                                                     {
                                                                         "carrier";
                                                                             {
                                                                                 "participant":
                                                                                     <xsl:for-each select="service">
                                                                                         <xsl:for-each select="carrier">
                                                                                             <xsl:for-each select="participant">
                                                                                                 {
                                                                                                     "businessName":"<xsl:value-of select="businessName" />" 
                                                                                                 }
                                                                                             </xsl:for-each>
                                                                                         </xsl:for-each>
                                                                                      </xsl:for-each>
                                                                              }
                                                                     } 
                                                             }

                                                       }
                                                       </xsl:for-each>
                                                     }
                                                 }
                                             </xsl:for-each>
                                    },
                                    {
                                     "specialInstructions":<xsl:value-of select="specialInstructions" />
                                    },
                                    {
                                     "rate":<xsl:value-of select="rate" />
                                    },
                                    {
                                     "rateIncSurcharge":<xsl:value-of select="rateIncSurcharge" />
                                    },
                                    {
                                     "rateWithoutMargin":<xsl:value-of select="rateWithoutMargin" />
                                    },
                                    {
                                     "rateWithoutMarginIncSurcharge":<xsl:value-of select="rateWithoutMarginIncSurcharge" />
                                    },
                                    {
                                     "weight":<xsl:value-of select="weight" />
                                    },
                                    {
                                     "volume":<xsl:value-of select="volume" />
                                    },
                                    {
                                     "extensions":<xsl:value-of select="extensions" />
                                    },
                                    {
                                     "lineItems":
                                         {
                                             "lineItem":
                                                 <xsl:for-each select="lineItems">
                                                     <xsl:for-each select="lineItem">
                                                     {
                                                         "id":<xsl:value-of select="id"/>
                                                     },
                                                     {
                                                         "volume":<xsl:value-of select="volume"/>
                                                     },
                                                     {
                                                         "weight":<xsl:value-of select="weight"/> 
                                                     },
                                                     {
                                                       "extensions":
                                                         {
                                                             "unconsolidatedLineItemRateExtension":
                                                                     <xsl:for-each select="extensions">
                                                                         <xsl:for-each select="unconsolidatedLineItemRateExtension">
                                                                             {

                                                                               "consolidatedBuyRate":<xsl:value-of select="consolidatedBuyRate" />,
                                                                               "consolidatedSellRate":<xsl:value-of select="consolidatedSellRate" />,
                                                                               "unConsolidatedBuyRate":<xsl:value-of select="unConsolidatedBuyRate" />,
                                                                               "unConsolidatedSellRate":<xsl:value-of select="unConsolidatedSellRate" />
                                                                             }
                                                                         </xsl:for-each>
                                                                     </xsl:for-each>
                                                         }
                                                     },
                                                     {
                                                       "container":
                                                             {
                                                                 "references":
                                                                     <xsl:for-each select="container">
                                                                         <xsl:for-each select="references">
                                                                             {
                                                                                 "reference":<xsl:value-of select="reference" />
                                                                             }
                                                                         </xsl:for-each>
                                                                     </xsl:for-each>
                                                             }
                                                     },
                                                     {
                                                       "totalLabels":<xsl:value-of select="totalLabels"/>
                                                     }
                                                     </xsl:for-each>
                                                </xsl:for-each>
                                         }
                                    },
                                    {
                                      "silentMode":<xsl:value-of select="silentMode" />
                                    },
                                    {
                                      "forceDespatchToCarrier":<xsl:value-of select="forceDespatchToCarrier" />
                                    },
                                    {
                                      "autoDespatch":<xsl:value-of select="autoDespatch" />
                                    },
                                    {
                                      "autoDeliver":<xsl:value-of select="autoDeliver" />
                                    },
                                    {
                                      "actualLongDespatchTime":<xsl:value-of select="actualLongDespatchTime" />
                                    },
                                    {
                                      "useSlaveDeliveryAddress":<xsl:value-of select="useSlaveDeliveryAddress" />
                                    }
                                  </xsl:for-each>
                              </xsl:for-each> 
                            }
                    }                   
                }
                </xsl:for-each>
            </xsl:for-each>
            }

    </xsl:template>
</xsl:stylesheet>

I am trying to get all the details of consinment but it is coming blank. Please help me as soon as possible.

* Edited after looking at the Gitter chat. *

@nitinagarwal78 First of all, are you even using Symphony CMS?

Nope.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details