简体   繁体   English

生成XSLT for XML Infopath表单

[英]Generate XSLT for XML Infopath Form

I need help on converting Infopath XML to XSLT its very challenging for me to convert. 我需要将Infopath XML转换为XSLT的帮助,这对我来说非常具有挑战性。 Can anyone help me on creating XSLT for the below XML. 谁能帮助我为以下XML创建XSLT。 This is an Infopath form i need help in creating Stylesheet for the xml which are created using the form library. 这是一个Infopath表单,我需要帮助来创建使用表单库创建的xml的样式表。

I tried to create XSLT but all gone in vein. 我尝试创建XSLT,但一切都一帆风顺。

            <?xml version="1.0" encoding="utf-8"?>
            <?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:Project-Setup:-myXSD-2018-03-14T07-59-16" solutionVersion="1.0.0.1013" productVersion="15.0.0.0" PIVersion="1.0.0.0" ?>
            <?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>
            <my:myFields>
                <my:RequestNo>ak123</my:RequestNo>
                <my:LOB>FA</my:LOB>
                <my:AreaFinMgr>

                <pc:Person xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls"><pc:DisplayName>FM</pc:DisplayName><pc:AccountId>i:0#.w|ad\fm</pc:AccountId><pc:AccountType>User</pc:AccountType></pc:Person></my:AreaFinMgr>
                <my:ProjMgr>

                <pc:Person xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls"><pc:DisplayName>NT</pc:DisplayName><pc:AccountId>i:0#.w|ad\nt</pc:AccountId><pc:AccountType>User</pc:AccountType></pc:Person></my:ProjMgr>
                <my:Approver>

                <pc:Person xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls"><pc:DisplayName>AT</pc:DisplayName><pc:AccountId>i:0#.w|ad\at</pc:AccountId><pc:AccountType>User</pc:AccountType></pc:Person></my:Approver>
                <my:InternalUse>
                    <my:PSStatus>Completed</my:PSStatus>
                    <my:PSComments></my:PSComments>
                    <my:PSby>
                        <pc:Person>
                            <pc:DisplayName>i:0#.w|ad\ga</pc:DisplayName>
                            <pc:AccountId></pc:AccountId>
                            <pc:AccountType></pc:AccountType>
                        </pc:Person>
                    </my:PSby>
                    <my:PSDate>2019-02-12</my:PSDate>
                    <my:Prod_by>
                        <pc:Person>
                            <pc:DisplayName>i:0#.w|ad\nr</pc:DisplayName>
                            <pc:AccountId></pc:AccountId>
                            <pc:AccountType></pc:AccountType>
                        </pc:Person>
                    </my:Prod_by>
                    <my:Prod_Date>2019-02-12</my:Prod_Date>
                </my:InternalUse>
                <my:Repeating>
                    <my:Item>
                        <my:RequestTYpe>1</my:RequestTYpe>
                        <my:RequestText>New Request</my:RequestText>
                        <my:NewSection>
                            <my:New>Project</my:New>
                            <my:Tier1>R</my:Tier1>
                            <my:Tier2>RAProj</my:Tier2>
                            <my:Tier3>RAMIn</my:Tier3>
                            <my:Tier4>RAM_N_P</my:Tier4>
                            <my:Tier5>RNUR</my:Tier5>
                            <my:Tier6></my:Tier6>
                            <my:Tier7></my:Tier7>
                            <my:Parent>RNUR</my:Parent>
                            <my:NIPP>ATRev</my:NIPP>
                            <my:PPC>XX1528</my:PPC>
                            <my:SpecialInstruction>Use project XX1528</my:SpecialInstruction>
                            <my:BudgetCode></my:BudgetCode>
                            <my:WorkType></my:WorkType>
                            <my:CAPPMLOB></my:CAPPMLOB>
                            <my:OpenTimeEntry></my:OpenTimeEntry>
                            <my:ClaritySpecialInst></my:ClaritySpecialInst>
                            <my:ITROI_StartDate xsi:nil="true"></my:ITROI_StartDate>
                            <my:ITROI_EndDate xsi:nil="true"></my:ITROI_EndDate>
                            <my:ITROI_Desc></my:ITROI_Desc>
                            <my:ITROI_RMC></my:ITROI_RMC>
                            <my:ITROI_IsProgIni>No</my:ITROI_IsProgIni>
                            <my:Temp1>
                                <pc:Person>
                                    <pc:DisplayName></pc:DisplayName>
                                    <pc:AccountId></pc:AccountId>
                                    <pc:AccountType></pc:AccountType>
                                </pc:Person>
                            </my:Temp1>
                            <my:Temp3></my:Temp3>
                            <my:Temp4>
                                <pc:Person>
                                    <pc:DisplayName></pc:DisplayName>
                                    <pc:AccountId></pc:AccountId>
                                    <pc:AccountType></pc:AccountType>
                                </pc:Person>
                            </my:Temp4>
                            <my:Temp5>
                                <pc:Person>
                                    <pc:DisplayName></pc:DisplayName>
                                    <pc:AccountId></pc:AccountId>
                                    <pc:AccountType></pc:AccountType>
                                </pc:Person>
                            </my:Temp5>
                            <my:field2></my:field2>
                            <my:EPMOVali>false</my:EPMOVali>
                            <my:Capitalization xsi:nil="true"></my:Capitalization>
                        </my:NewSection>
                        <my:DescChange>
                            <my:DescNew></my:DescNew>
                            <my:DescIPP></my:DescIPP>
                            <my:DescName></my:DescName>
                            <my:DescNewName></my:DescNewName>
                            <my:DescSpecial></my:DescSpecial>
                        </my:DescChange>
                        <my:Rollup>
                            <my:RollNew></my:RollNew>
                            <my:RollIPP></my:RollIPP>
                            <my:RollNewLoc></my:RollNewLoc>
                            <my:RollSpecial></my:RollSpecial>
                        </my:Rollup>
                    </my:Item>
                </my:Repeating>
                <my:ClickStatus>PPC_Created</my:ClickStatus>
                <my:listName>1</my:listName>
                <my:formName></my:formName>
                <my:ReasonForRequest>Projt</my:ReasonForRequest>
                <my:EPMO_Field>false</my:EPMO_Field>
                <my:LOB_PMO></my:LOB_PMO>
                <my:Billable>Yes</my:Billable>
            </my:myFields>

Request No LOB PSStatus New Parent NIPP PPC ak123 FA Completed Project RNUR ATRev XX1528 请求没有LOB PSStatus新的父级NIPP PPC ak123 FA已完成项目RNUR ATRev XX1528

This is what i tried 这就是我尝试过的

            <?xml version="1.0" encoding="UTF-8"?>
            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:template match="/">
            <html> 
            <body>
              <h2>My CD Collection</h2>
              <table border="1">
                <tr bgcolor="#9acd32">
                  <th style="text-align:left">Request No</th>
                  <th style="text-align:left">LOB</th>
                  <th style="text-align:left">PSStatus</th>
                  <th style="text-align:left">New Parent</th>
                  <th style="text-align:left">NIPP</th>
                  <th style="text-align:left">PPC</th>
                </tr>
                <xsl:for-each select="my:myFields/my:Repeating">
                <tr>
                  <td><xsl:value-of select="my:myFields/my:RequestNo" /></td>
                  <td><xsl:value-of select="my:myFields/my:LOB"/></td>
                  <td><xsl:value-of select="my:myFields/my:InternalUse/my:PSStatus"/></td>
                  <td><xsl:value-of select="my:myFields/my:Repeating/my:Item"/></td>
                  <td><xsl:value-of select="my:myFields/my:Repeating/my:Item/my:NIPP"/></td>
                  <td><xsl:value-of select="my:myFields/my:Repeating/my:Item/my:PPC"/></td>
                </tr>
                </xsl:for-each>
              </table>
            </body>
            </html>
            </xsl:template>
            </xsl:stylesheet>

As I said in a comment to your question, your input is not a well-formed XML document and cannot be processed by XSLT. 正如我在对您的问题的评论中所说的那样,您输入的内容不是格式正确的XML文档,因此XSLT无法对其进行处理。

If you had a well-formed XML input such as: 如果您有格式正确的XML输入,例如:

XML XML

<my:myFields xmlns:my="http://example.com/my" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <my:RequestNo>ak123</my:RequestNo>
  <my:LOB>FA</my:LOB>
  <my:AreaFinMgr>
    <pc:Person>
      <pc:DisplayName>FM</pc:DisplayName>
      <pc:AccountId>i:0#.w|ad\fm</pc:AccountId>
      <pc:AccountType>User</pc:AccountType>
    </pc:Person>
  </my:AreaFinMgr>
  <my:ProjMgr>
    <pc:Person>
      <pc:DisplayName>NT</pc:DisplayName>
      <pc:AccountId>i:0#.w|ad\nt</pc:AccountId>
      <pc:AccountType>User</pc:AccountType>
    </pc:Person>
  </my:ProjMgr>
  <my:Approver>
    <pc:Person>
      <pc:DisplayName>AT</pc:DisplayName>
      <pc:AccountId>i:0#.w|ad\at</pc:AccountId>
      <pc:AccountType>User</pc:AccountType>
    </pc:Person>
  </my:Approver>
  <my:InternalUse>
    <my:PSStatus>Completed</my:PSStatus>
    <my:PSComments/>
    <my:PSby>
      <pc:Person>
        <pc:DisplayName>i:0#.w|ad\ga</pc:DisplayName>
        <pc:AccountId/>
        <pc:AccountType/>
      </pc:Person>
    </my:PSby>
    <my:PSDate>2019-02-12</my:PSDate>
    <my:Prod_by>
      <pc:Person>
        <pc:DisplayName>i:0#.w|ad\nr</pc:DisplayName>
        <pc:AccountId/>
        <pc:AccountType/>
      </pc:Person>
    </my:Prod_by>
    <my:Prod_Date>2019-02-12</my:Prod_Date>
  </my:InternalUse>
  <my:Repeating>
    <my:Item>
      <my:RequestTYpe>1</my:RequestTYpe>
      <my:RequestText>New Request</my:RequestText>
      <my:NewSection>
        <my:New>Project</my:New>
        <my:Tier1>R</my:Tier1>
        <my:Tier2>RAProj</my:Tier2>
        <my:Tier3>RAMIn</my:Tier3>
        <my:Tier4>RAM_N_P</my:Tier4>
        <my:Tier5>RNUR</my:Tier5>
        <my:Tier6/>
        <my:Tier7/>
        <my:Parent>RNUR</my:Parent>
        <my:NIPP>ATRev</my:NIPP>
        <my:PPC>XX1528</my:PPC>
        <my:SpecialInstruction>Use project XX1528</my:SpecialInstruction>
        <my:BudgetCode/>
        <my:WorkType/>
        <my:CAPPMLOB/>
        <my:OpenTimeEntry/>
        <my:ClaritySpecialInst/>
        <my:ITROI_StartDate xsi:nil="true"/>
        <my:ITROI_EndDate xsi:nil="true"/>
        <my:ITROI_Desc/>
        <my:ITROI_RMC/>
        <my:ITROI_IsProgIni>No</my:ITROI_IsProgIni>
        <my:Temp1>
          <pc:Person>
            <pc:DisplayName/>
            <pc:AccountId/>
            <pc:AccountType/>
          </pc:Person>
        </my:Temp1>
        <my:Temp3/>
        <my:Temp4>
          <pc:Person>
            <pc:DisplayName/>
            <pc:AccountId/>
            <pc:AccountType/>
          </pc:Person>
        </my:Temp4>
        <my:Temp5>
          <pc:Person>
            <pc:DisplayName/>
            <pc:AccountId/>
            <pc:AccountType/>
          </pc:Person>
        </my:Temp5>
        <my:field2/>
        <my:EPMOVali>false</my:EPMOVali>
        <my:Capitalization xsi:nil="true"/>
      </my:NewSection>
      <my:DescChange>
        <my:DescNew/>
        <my:DescIPP/>
        <my:DescName/>
        <my:DescNewName/>
        <my:DescSpecial/>
      </my:DescChange>
      <my:Rollup>
        <my:RollNew/>
        <my:RollIPP/>
        <my:RollNewLoc/>
        <my:RollSpecial/>
      </my:Rollup>
    </my:Item>
  </my:Repeating>
  <my:ClickStatus>PPC_Created</my:ClickStatus>
  <my:listName>1</my:listName>
  <my:formName/>
  <my:ReasonForRequest>Projt</my:ReasonForRequest>
  <my:EPMO_Field>false</my:EPMO_Field>
  <my:LOB_PMO/>
  <my:Billable>Yes</my:Billable>
</my:myFields>

then you could use: 那么您可以使用:

XSLT 1.0 XSLT 1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="http://example.com/my"
exclude-result-prefixes="my">
<xsl:output method="html" encoding="utf-8"/>

<xsl:template match="/">
    <html> 
        <body>
            <h2>put your own title here</h2>
            <table border="1">
                <tr>
                <th>Request No</th>
                <th>LOB</th>
                <th>PSStatus</th>
                <th>New Parent</th>
                <th>NIPP</th>
                <th>PPC</th>
            </tr>
            <xsl:for-each select="my:myFields/my:Repeating">
                <tr>
                    <td><xsl:value-of select="../my:RequestNo" /></td>
                    <td><xsl:value-of select="..//my:LOB"/></td>
                    <td><xsl:value-of select="../my:InternalUse/my:PSStatus"/></td>
                    <td><xsl:value-of select="my:Item/my:NewSection/my:New"/></td>
                    <td><xsl:value-of select="my:Item/my:NewSection/my:NIPP"/></td>
                    <td><xsl:value-of select="my:Item/my:NewSection/my:PPC"/></td>
                </tr>
            </xsl:for-each>
            </table>
        </body>
    </html>
</xsl:template>

</xsl:stylesheet>

to get: 要得到:

Result 结果

<html>
<body>
<h2>put your own title here</h2>
<table border="1">
<tr>
<th>Request No</th>
<th>LOB</th>
<th>PSStatus</th>
<th>New Parent</th>
<th>NIPP</th>
<th>PPC</th>
</tr>
<tr>
<td>ak123</td>
<td>FA</td>
<td>Completed</td>
<td>Project</td>
<td>ATRev</td>
<td>XX1528</td>
</tr>
</table>
</body>
</html>

Note the namespace handling in the xsl:stylesheet open tag. 请注意xsl:stylesheet open标记中的名称空间处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM