xml样式表for-each

时间:2016-05-20 07:52:40

标签: xml xslt

我想让每个雇主和他所有的工作都在工作台上 我无法在for-each中获得EmpID 尝试嵌套for-each但在select =“”中遇到冲突 我尝试将select语句更改为

  

选择=“EmploymnetService /雇主

并在每个作业值中添加这样的额外目录

  

value-of select =“@ EmployerJobAds / JobAd / JobId”

但只有每个雇主的第一份工作显而易见:-P

我有以下的xml文件

SELECT  clashhid,
        TaDah,
        DahTaPanz,
        PanzTaBist,
        BistTaBispan,
        BispanTaC ,
        mariStatus
  FROM asli CROSS JOIN (VALUES ('single'),('married')) AS custs (mariStatus)

和xslt

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="employerStyle.xsl"?>
<EmploymnetService>
    <Employer employerId="1">
        <EmployerName>Ahmad</EmployerName>
        <EmployerAddress>Gaza</EmployerAddress>
        <EmployerEmail>ahmad.abuabdou@live.com</EmployerEmail>
        <EmployerPhone>0598787121</EmployerPhone>
        <EmployerJobAds >
            <JobAd JobId="1" >
                <jobTitle>Programmer</jobTitle>
                <jobDescription>Developer</jobDescription>
                <QualificationsRequired>
                    <QLevel>PhD</QLevel>
                    <QName>Developer</QName>
                    <QFaculty>IT</QFaculty>
                    <QUniversity>Azhar Univircity of Gaza</QUniversity>
                    <QGrade>Excellent</QGrade>
                    <gradDate>1995-04-19</gradDate>
                </QualificationsRequired>
                <ExperienceRequired>
                    <ExpPosition>Programmer</ExpPosition>
                    <expDescription>Developer</expDescription>
                    <expEmployer>Pro</expEmployer>
                    <expFrom>2012-10-26</expFrom>
                    <expTo>2016-11-26</expTo>
                </ExperienceRequired>
            </JobAd>
            <JobAd JobId="2" >
                <jobTitle>Programmer</jobTitle>
                <jobDescription>Developer</jobDescription>
                <QualificationsRequired>
                    <QLevel>PhD</QLevel>
                    <QName>Developer</QName>
                    <QFaculty>IT</QFaculty>
                    <QUniversity>Azhar Univircity of Gaza</QUniversity>
                    <QGrade>Excellent</QGrade>
                    <gradDate>1995-04-19</gradDate>
                </QualificationsRequired>
                <ExperienceRequired>
                    <ExpPosition>Programmer</ExpPosition>
                    <expDescription>Developer</expDescription>
                    <expEmployer>Pro</expEmployer>
                    <expFrom>2012-10-26</expFrom>
                    <expTo>2016-11-26</expTo>
                </ExperienceRequired>
            </JobAd>
        </EmployerJobAds>
    </Employer>

    <Employer employerId="2">
        <EmployerName>Ahmad</EmployerName>
        <EmployerAddress>Gaza</EmployerAddress>
        <EmployerEmail>ahmad.abuabdou@live.com</EmployerEmail>
        <EmployerPhone>0598787121</EmployerPhone>
        <EmployerJobAds >
            <JobAd JobId="3" >
                <jobTitle>Programmer</jobTitle>
                <jobDescription>Developer</jobDescription>
                <QualificationsRequired>
                    <QLevel>PhD</QLevel>
                    <QName>Developer</QName>
                    <QFaculty>IT</QFaculty>
                    <QUniversity>Azhar Univircity of Gaza</QUniversity>
                    <QGrade>Excellent</QGrade>
                    <gradDate>1995-04-19</gradDate>
                </QualificationsRequired>
                <ExperienceRequired>
                    <ExpPosition>Programmer</ExpPosition>
                    <expDescription>Developer</expDescription>
                    <expEmployer>Pro</expEmployer>
                    <expFrom>2012-10-26</expFrom>
                    <expTo>2016-11-26</expTo>
                </ExperienceRequired>
            </JobAd>
        </EmployerJobAds>
    </Employer>


</EmploymnetService>

这是我到目前为止所得到的 enter image description here

1 个答案:

答案 0 :(得分:0)

  

我无法在for-each

中获得EmpID

<xsl:for-each select="EmploymnetService/Employer/EmployerJobAds/JobAd">区块中,更改:

<td><xsl:value-of select="@employerId"/></td>

为:

<td><xsl:value-of select="ancestor::Employer/@employerId"/></td>