2013-07-24 59 views
4

我试图通过XSLT将我的XML转换为HTML ...并基于另一种情况,提出了以下内容。在XML @ my:myFields/my:CargoItemsSection中有一个“重复表”数据...我希望将这些数据放入一个表中,并忽略“my:myFields”中的所有其他字段......实际上,XSLT下面不产生任何东西;我得到一个空白的结果。 ?:(任何想法使用XSLT映射XML数据

//更新 - XML文件张贴楼下:)

<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-12-05T14:55:38" 
    exclude-result-prefixes="my"> 

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

    <xsl:template match="/"> 
    <xsl:apply-templates select="my:myFields"/> 
    </xsl:template> 

    <xsl:template match="my:myFields"> 
    <table border="1" cellpadding="1"> 
     <tr bgcolor="skyblue"> 
     <th>Equ</th> 
     <th>#Items</th> 
     <th>Commodity</th> 
     <th>Dimensions</th> 
     <th>Weight</th> 
     <th>CENSPC Action</th> 
     <th>Quote Type</th> 
     <th>Quote</th> 
     <th>QM Ref</th> 
     <th>QM Text</th> 
     </tr> 
     <xsl:apply-templates select="my:CargoItemsSection"/> 
    </table> 
    </xsl:template> 

    <xsl:template match="my:CargoItemsSection"> 
    <tr align="center"> 
     <td><xsl:value-of select="my:Equipment-Size" /><xsl:value-of select="my:Equipment-Type" /></td> 
     <td><xsl:value-of select="my:NumberOfContainers" /></td> 
     <td><xsl:value-of select="my:CommodityName" /></td> 
     <td>L:<xsl:value-of select="my:Length" />,W:<xsl:value-of select="my:Width" />,H:<xsl:value-of select="my:Height" /></td> 
     <td><xsl:value-of select="my:Weight" /></td> 
     <td><xsl:value-of select="my:AcceptedOrRejected" /></td> 
     <td><xsl:value-of select="my:QuoteAmountType" /></td> 
     <td><xsl:value-of select="my:QuoteAmount" /> <xsl:value-of select="my:Currency" /></td> 
     <td><xsl:value-of select="my:QMReferenceNumber" /></td> 
     <td><xsl:value-of select="my:QuoteText" /></td> 
    </tr> 
    </xsl:template> 

</xsl:stylesheet> 

XML文件:

<?xml version="1.0" encoding="utf-8"?> 
<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:SPC--Special-Cargo:-myXSD-2013-04-09T08-39-48" solutionVersion="1.0.0.1816" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="http://team.apmoller.net/sites/NNP-One-Stop-Shop/SPC%20%20Special%20Cargo/Forms/template.xsn"?> 
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?> 
<?mso-infoPath-file-attachment-present?> 
<my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:ma="http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes" xmlns:d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields" xmlns:q="http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:dms="http://schemas.microsoft.com/office/2009/documentManagement/types" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-04-09T08:39:48" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-US"> 
    <my:SpecialCargoTeamSection> 
     <my:ActionTaken></my:ActionTaken> 
     <my:SCTComment>In order to make a detailed handling assessment and to verify unitised/OOG handling with the applicable terminals, appreciate if you can provide a provide a technical drawing (ideally) or a photo of the cargo detailing cargo configuration and location of center of gravity.</my:SCTComment> 
     <my:QMAttachment xsi:nil="true"></my:QMAttachment> 
     <my:ActionTakenReEval></my:ActionTakenReEval> 
     <my:AmountForCounterOffer xsi:nil="true"></my:AmountForCounterOffer> 
     <my:RequestedRateAmountTypeSPC></my:RequestedRateAmountTypeSPC> 
     <my:formReEvalCounterOfferClicked>false</my:formReEvalCounterOfferClicked> 
     <my:SCTReviewer>VPI015</my:SCTReviewer> 
     <my:AssignToGSC>false</my:AssignToGSC> 
     <my:frmStatusChecker>0</my:frmStatusChecker> 
     <my:FinalOffer>false</my:FinalOffer> 
     <my:QuoteAmountChangeCounter>0</my:QuoteAmountChangeCounter> 
    </my:SpecialCargoTeamSection> 
    <my:RequestTypeSection> 
     <my:RequestType>OOG Quotation</my:RequestType> 
     <my:RequestType_ReEval></my:RequestType_ReEval> 
    </my:RequestTypeSection> 
    <my:RequestFields> 
     <my:SalesPerson>ARA202</my:SalesPerson> 
     <my:RequestOnBehalfOf>MF_GSCSCLNEUQTCCRB\gscsclneuqtcUser</my:RequestOnBehalfOf> 
     <my:Brand>SAFMARINE</my:Brand> 
     <my:ContractualCustomerCode></my:ContractualCustomerCode> 
     <my:ShipmentDate xsi:nil="true"></my:ShipmentDate> 
     <my:CustomerOrShipperName>CEVA Logistics </my:CustomerOrShipperName> 
     <my:Origin>UAE</my:Origin> 
     <my:Destination>Qatar</my:Destination> 
     <my:OriginPortNameOrCODE>Jebel Ali</my:OriginPortNameOrCODE> 
     <my:DestinationPortNameCODE>Doha</my:DestinationPortNameCODE> 
     <my:RequestComment>Phote of the cargo attached</my:RequestComment> 
     <my:Region>EUR</my:Region> 
     <my:PersonOnBehalfOf> 

     <pc:Person xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls"><pc:DisplayName>MF_GSCSCLNEUQTC</pc:DisplayName><pc:AccountId>CRB\gscsclneuqtc</pc:AccountId><pc:AccountType>User</pc:AccountType></pc:Person><pc:Person xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls"><pc:DisplayName>Khatua, Pankaj</pc:DisplayName><pc:AccountId>CRB\PKH025</pc:AccountId><pc:AccountType>User</pc:AccountType></pc:Person><pc:Person xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls"><pc:DisplayName>Ramasamy, Vivek</pc:DisplayName><pc:AccountId>CRB\VRA083</pc:AccountId><pc:AccountType>User</pc:AccountType></pc:Person></my:PersonOnBehalfOf> 
     <my:CommodityDescription></my:CommodityDescription> 
     <my:WaitingOnCustomerLabelSection></my:WaitingOnCustomerLabelSection> 
     <my:group7></my:group7> 
     <my:group8></my:group8> 
     <my:group9></my:group9> 
     <my:group10></my:group10> 
     <my:RequestorPerson> 
      <pc:Person> 
       <pc:DisplayName></pc:DisplayName> 
       <pc:AccountId>ARA202</pc:AccountId> 
       <pc:AccountType></pc:AccountType> 
      </pc:Person> 
     </my:RequestorPerson> 
     <my:DestRegion>EUR</my:DestRegion> 
     <my:RequestorReference>Fw: Invitation to bid SP2013072300025 FROM AE TO QA</my:RequestorReference> 
     <my:OnBehalfOfConcat>MF_GSCSCLNEUQTC;Khatua, Pankaj;Ramasamy, Vivek;</my:OnBehalfOfConcat> 
    </my:RequestFields> 
    <my:ReEvaluationSection> 
     <my:ReasonForReevaluation></my:ReasonForReevaluation> 
     <my:RequestedValidityExpireDate xsi:nil="true"></my:RequestedValidityExpireDate> 
     <my:VolumePlusTimePeriod></my:VolumePlusTimePeriod> 
     <my:CompetitionInformation></my:CompetitionInformation> 
     <my:RequestedRateAmountType></my:RequestedRateAmountType> 
     <my:RequestedRateAmount xsi:nil="true"></my:RequestedRateAmount> 
     <my:RateAmountDetail></my:RateAmountDetail> 
     <my:OtherReasonofReEvaluation></my:OtherReasonofReEvaluation> 
     <my:AmountCurrency></my:AmountCurrency> 
     <my:QMRefNumberForReEvaluation></my:QMRefNumberForReEvaluation> 
     <my:ReasonForReevalSection></my:ReasonForReevalSection> 
     <my:NotBASRateSubjectToSection></my:NotBASRateSubjectToSection> 
     <my:OtherReasonSection></my:OtherReasonSection> 
     <my:group3></my:group3> 
    </my:ReEvaluationSection> 
    <my:CargoItemsSection> 
     <my:Length>1010</my:Length> 
     <my:Width>410</my:Width> 
     <my:Height>460</my:Height> 
     <my:Weight>20000</my:Weight> 
     <my:AcceptedOrRejected>Clarification Needed</my:AcceptedOrRejected> 

     <my:QuotePdfAttachment xsi:nil="true"></my:QuotePdfAttachment> 
     <my:QuoteAmountType></my:QuoteAmountType> 
     <my:Currency></my:Currency> 
     <my:QuoteAmount xsi:nil="true"></my:QuoteAmount> 
     <my:QMReferenceNumber></my:QMReferenceNumber> 
     <my:Equipment-Type>Flat Rack</my:Equipment-Type> 
     <my:Equipment-Size>40</my:Equipment-Size> 
     <my:CommodityName>Machinery</my:CommodityName> 
     <my:group1></my:group1> 
     <my:NumberOfContainers xsi:nil="true"></my:NumberOfContainers> 
     <my:QuoteText></my:QuoteText> 
     <my:WaitingOnCustomer></my:WaitingOnCustomer> 
     <my:group5></my:group5> 
     <my:field6></my:field6> 
     <my:field7></my:field7> 
     <my:field8></my:field8> 
     <my:field9></my:field9> 
    </my:CargoItemsSection> 
    <my:AcceptedViewSection> 
     <my:ReasonForAcceptance></my:ReasonForAcceptance> 
     <my:OtherReasonOfAccept></my:OtherReasonOfAccept> 
    </my:AcceptedViewSection> 
    <my:RejectViewSection> 
     <my:ReasonForRejection></my:ReasonForRejection> 
     <my:OtherReasonForRejection></my:OtherReasonForRejection> 
    </my:RejectViewSection> 
    <my:FormAndButtons> 
     <my:SpecialCargoType>OOG</my:SpecialCargoType> 
     <my:FormAction></my:FormAction> 
     <my:NonReEvalButtonSection></my:NonReEvalButtonSection> 
     <my:RequestStatus>Pending SPC Review</my:RequestStatus> 
     <my:LastUpdateFrom>Form</my:LastUpdateFrom> 
     <my:IsFormEdit>true</my:IsFormEdit> 
     <my:Approvers>VPI015; CCH052; SSJ032; JEL025; XMZ004; ABO055; PKU014; SJD015; TDA042; TRA071; KRA126; DRA108; VIR004; KLU007</my:Approvers> 
     <my:ProcessStatus>Active</my:ProcessStatus> 
     <my:FileName>SPC_2013-07-24T04:43:09_ARA202</my:FileName> 
     <my:ReEvalViewSection></my:ReEvalViewSection> 
     <my:RequestID>1</my:RequestID> 
     <my:frmCurrentView>Request Form</my:frmCurrentView> 
     <my:TestSection> 
      <my:CurrentUser> 
       <pc:Person> 
        <pc:DisplayName></pc:DisplayName> 
        <pc:AccountId>VRA083</pc:AccountId> 
        <pc:AccountType></pc:AccountType> 
       </pc:Person> 
      </my:CurrentUser> 
      <my:field5></my:field5> 
     </my:TestSection> 
     <my:RequestTypeDescription>Choose this option to get a quotation for an Out Of Gauge rate based on cargo dimensions, weight, origin/destination and standard cost involved for the shipment.</my:RequestTypeDescription> 
     <my:IsNewRequest>false</my:IsNewRequest> 
     <my:EmailSubscription>false</my:EmailSubscription> 
     <my:TestFieldData></my:TestFieldData> 
     <my:frmCounterOfferDisplayHelp>Please update the details in the request form below and save to submit your counteroffer.</my:frmCounterOfferDisplayHelp> 
     <my:CustomerResponse></my:CustomerResponse> 
     <my:frmWaitingOnCustomerHelp>The SPC team will not review the request further until you un-tick all "Waiting on Customer" boxes.</my:frmWaitingOnCustomerHelp> 
     <my:Access>Requestor</my:Access> 
     <my:Engine>ClarificationResponse</my:Engine> 
     <my:UndoGSCAssignment>false</my:UndoGSCAssignment> 
     <my:frmCurrentUser>vra083</my:frmCurrentUser> 
     <my:frmCargoLineItemValidator>0</my:frmCargoLineItemValidator> 
     <my:IntroText></my:IntroText> 
     <my:ListItemID>SPC2369</my:ListItemID> 
     <my:RequestorEmail>mailto:ARA202?subject=Regarding Special Cargo Request SPC2369&amp;cc=</my:RequestorEmail> 
     <my:RequestorMySite>http://my.apmoller.net/person.aspx?accountname=CRB%5CARA202</my:RequestorMySite> 
    </my:FormAndButtons> 
    <my:TimeStamps> 
     <my:RepliedBy></my:RepliedBy> 
     <my:RepliedOnTimestamp xsi:nil="true"></my:RepliedOnTimestamp> 
     <my:CloseTimestamp xsi:nil="true"></my:CloseTimestamp> 
    </my:TimeStamps> 
    <my:group2> 
     <my:field3></my:field3> 
     <my:field4></my:field4> 
    </my:group2> 
    <my:group6></my:group6> 
    <my:field10></my:field10> 
    <my:group11></my:group11> 
</my:myFields> 
+0

你可以在这里放置你的XML文件吗? – kpater87

+0

完成 - 添加了XML文件。 – runelynx

回答

2

你有my前缀映射到两个不同的命名空间的URI。在XML文档中它的

http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-04-09T08:39:48 

,并在XSLT是

http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-12-05T14:55:38 

因此你的对手并选择,因为他们正在寻找在错误的命名空间的元素表达式匹配什么。

+0

试试.... – runelynx

+0

ahhhhhh !!!有用 !非常感谢你:))我真的不明白这个地址的意义是什么......但它的工作原理! – runelynx

+0

@runelynx它不是一个“地址”,但它构成了各种元素的身份的一部分。在你的XML中,你有一个元素的名字实际上是“'{http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-04-09T08:39:48} myFields'”,但你的XSLT正在寻找对于名称为“{http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-12-05T14:55:38} myFields'”的人。如果您搜索“XML名称空间”,网络上有很多信息。 –