这是我第一次在这里发帖,所以我提前为篇幅和任何格式问题或信息不足道歉。我已经处理这个问题几天了,我已经对我的问题进行了广泛的研究,但还没有找到解决方案,所以我希望这里的人能帮助我。这是一个与xslt相关的问题,我几个月前才开始用xslt编码,所以我没有那么多经验。
基本上,我有一个输入XML,它可能包含重复的记录和空标记,我需要将它们重新组织成一个javascript关联数组,以便能够在客户端有效地操作和显示值。
我的问题是:即使使用的字段标记为空,是否有方法进行多级分组。如果没有,有没有一种方法可以在xsl中编辑xml,用关键字替换空标记,然后应用我的其余模板
要理解我的问题,这里是细节。这是我的输入XML
<cds>
<sections>
<section name="myteam_CurrentAgeCompleteSection" link="false">
<detail name="">
<record>
<field name="AGERANGEID">30-39</field>
<field name="NUMOFCOUNTAGE">1</field>
<field name="ORGUNITID">00001001</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITNAME">Human Resources</field>
</record>
<record>
<field name="AGERANGEID">>=70</field>
<field name="NUMOFCOUNTAGE">5</field>
<field name="ORGUNITID">00001001</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITNAME">Human Resources</field>
</record>
</detail>
</section>
<section name="myteam_CurrentGenderCompleteSection" link="false">
<detail name="">
<record>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="ORGUNITNAME">Human Resources</field>
<field name="NUMOFGENDERCOUNT">5</field>
<field name="GENDER">2</field>
</record>
<record>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="ORGUNITNAME">Human Resources</field>
<field name="NUMOFGENDERCOUNT">7</field>
<field name="GENDER">1</field>
</record>
</detail>
</section>
<section name="myteam_CurrentRaceCompleteSection" link="false">
<detail name="">
<record>
<field name="ORGUNITNAME">Human Resources</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="NUMOFRACE">10.0</field>
<field name="RACENAME" />
</record>
<record>
<field name="ORGUNITNAME">Human Resources</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="NUMOFRACE">1</field>
<field name="RACENAME">Asian</field>
</record>
<record>
<field name="ORGUNITNAME">Human Resources</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="NUMOFRACE">1</field>
<field name="RACENAME">American Indian</field>
</record>
</detail>
</section>
<section name="myteam_ChildAgeColumnSection" link="false">
<detail name="">
<record>
<field name="AGERANGEID">40-49</field>
<field name="NUMOFCOUNTAGE">1</field>
<field name="ORGUNITID">50000013</field>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
</record>
<record>
<field name="AGERANGEID">50-59</field>
<field name="NUMOFCOUNTAGE">2</field>
<field name="ORGUNITID">50000013</field>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
</record>
<record>
<field name="AGERANGEID">>=70</field>
<field name="NUMOFCOUNTAGE">5</field>
<field name="ORGUNITID">50000013</field>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
</record>
</detail>
</section>
<section name="myteam_ChildGenderColumnSection" link="false">
<detail name="">
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">2</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000147</field>
<field name="ORGUNITNAME">Personnel Administration (D)</field>
<field name="NUMOFGENDERCOUNT">3</field>
<field name="GENDER">1</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">1</field>
</record>
</detail>
</section>
<section name="myteam_ChildGenderColumnSection" link="false">
<detail name="">
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">2</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000147</field>
<field name="ORGUNITNAME">Personnel Administration (D)</field>
<field name="NUMOFGENDERCOUNT">3</field>
<field name="GENDER">1</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">1</field>
</record>
</detail>
</section>
<section name="myteam_ChildGenderColumnSection" link="false">
<detail name="">
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">2</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000147</field>
<field name="ORGUNITNAME">Personnel Administration (D)</field>
<field name="NUMOFGENDERCOUNT">3</field>
<field name="GENDER">1</field>
</record>
</detail>
</section>
</sections>
</cds>
我在网上查看了一下,发现处理多级分组的最佳方法是使用xsl:key和generate-id()。这样做效果很好,数据也完全符合我的要求,所以xsl的流程是正确的。但是不幸的是,如果xsl:key中使用的字段是一个空标记,那么当我使用concat()进行多级分组时,它就会失败。
<!-- Start external variables -->
<!-- Field names -->
<xsl:variable name="ageFieldName" select="'AGERANGEID'" />
<xsl:variable name="genderFieldName" select="'GENDER'" />
<xsl:variable name="raceFieldName" select="'RACENAME'" />
<xsl:variable name="ouIdFieldName" select="'ORGUNITID'" />
<xsl:variable name="ouNameFieldName" select="'ORGUNITNAME'" />
<!-- Keys -->
<xsl:key use="field[@name='AGERANGEID']" name="AGERANGEID" match="detail/record" />
<xsl:key use="concat(field[@name='AGERANGEID'],'|', field[@name='ORGUNITID'])" name="AGERANGEID_merge" match="detail/record" />
<xsl:key use="field[@name='GENDER']" name="GENDER" match="detail/record" />
<xsl:key use="concat(field[@name='GENDER'],'|', field[@name='ORGUNITID'])" name="GENDER_merge" match="detail/record" />
<xsl:key use="field[@name='RACENAME']" name="RACENAME" match="detail/record" />
<xsl:key use="concat(field[@name='RACENAME'],'|', field[@name='ORGUNITID'])" name="RACENAME_merge" match="detail/record" />
<xsl:key use="field[@name='ORGUNITID']" name="ORGUNITID" match="detail/record" />
<xsl:template match="/">
var analyticsMap = {<xsl:call-template name="buildAnalyticsTable" />};
</xsl:template>
<xsl:template name="buildAnalyticsTable">
<!-- Age -->
"<xsl:value-of select="$ageFieldName"/>" : {
<xsl:apply-templates mode="buildAnalyticsTableRangeLevel" select="//detail/record[generate-id()=generate-id(key($ageFieldName, field[@name=$ageFieldName]))]">
<xsl:with-param name="keyName" select="$ageFieldName"/>
<xsl:with-param name="countField" select="'NUMOFCOUNTAGE'"/>
<xsl:with-param name="label" select="'Age Range'" />
<xsl:with-param name="isGender" select="'false'" />
</xsl:apply-templates>
},
<!-- Gender -->
"<xsl:value-of select="$genderFieldName"/>" : {
<xsl:apply-templates mode="buildAnalyticsTableRangeLevel" select="//detail/record[generate-id()=generate-id(key($genderFieldName, field[@name=$genderFieldName]))]">
<xsl:with-param name="keyName" select="$genderFieldName"/>
<xsl:with-param name="countField" select="'NUMOFGENDERCOUNT'"/>
<xsl:with-param name="label" select="'Gender'" />
<xsl:with-param name="isGender" select="'true'" />
</xsl:apply-templates>
},
<!-- Race -->
"<xsl:value-of select="$raceFieldName"/>" : {
<xsl:apply-templates mode="buildAnalyticsTableRangeLevel" select="//detail/record[generate-id()=generate-id(key($raceFieldName, field[@name=$raceFieldName]))]">
<xsl:with-param name="keyName" select="$raceFieldName"/>
<xsl:with-param name="countField" select="'NUMOFRACE'"/>
<xsl:with-param name="label" select="'Race'" />
<xsl:with-param name="isGender" select="'true'" />
</xsl:apply-templates>
}
</xsl:template>
<xsl:template match="detail/record" mode="buildAnalyticsTableRangeLevel">
<xsl:param name="keyName" />
<xsl:param name="countField" />
<xsl:param name="label" />
<xsl:param name="isGender" />
<xsl:variable name="value" >
<xsl:call-template name="testForUnknown">
<xsl:with-param name="name" select="field[@name=$keyName]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="name">
<xsl:call-template name="testForGender">
<xsl:with-param name="isGender" select="$isGender"/>
<xsl:with-param name="name" select="$value"/>
</xsl:call-template>
</xsl:variable>
"<xsl:value-of select="$value"/>" : {
"analyticsLabel" : "<xsl:value-of select="$label"/>",
"analyticsName" : "<xsl:value-of select="$name"/>",
<xsl:apply-templates mode="buildAnalyticsTableCountLevel" select="key($keyName, field[@name=$keyName])[generate-id()=generate-id(key(concat($keyName, '_merge'), concat(field[@name=$keyName],'|', field[@name=$ouIdFieldName])))]">
<xsl:with-param name="countField" select="$countField"/>
</xsl:apply-templates>
},
</xsl:template>
<xsl:template match="detail/record" mode="buildAnalyticsTableCountLevel">
<xsl:param name="countField" />
"<xsl:value-of select="field[@name=$ouIdFieldName]"/>" : {
"analyticsOUname" : "<xsl:value-of select="field[@name=$ouNameFieldName]"/>",
"analyticsValue" : "<xsl:value-of select="field[@name=$countField]"/>"
},
</xsl:template>
<xsl:template name="testForUnknown">
<xsl:param name="name" />
<xsl:choose>
<xsl:when test="string-length($name) = 0">
<xsl:value-of select="'Unknown'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$name" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="testForGender">
<xsl:param name="isGender" />
<xsl:param name="name" />
<xsl:choose>
<xsl:when test="$isGender = 'true' and $name = 1">
<xsl:value-of select="'male'" />
</xsl:when>
<xsl:when test="$isGender = 'true' and $name = 2">
<xsl:value-of select="'female'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$name" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
这是我的转换的输出
var analyticsMap = {
"AGERANGEID" : {
"30-39" : {
"analyticsLabel" : "Age Range",
"analyticsName" : "30-39",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "1"
},
},
">=70" : {
"analyticsLabel" : "Age Range",
"analyticsName" : ">=70",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "5"
},
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "5"
},
},
"40-49" : {
"analyticsLabel" : "Age Range",
"analyticsName" : "40-49",
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "1"
},
},
"50-59" : {
"analyticsLabel" : "Age Range",
"analyticsName" : "50-59",
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "2"
},
},
},
"GENDER" : {
"2" : {
"analyticsLabel" : "Gender",
"analyticsName" : "female",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "5"
},
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "4"
},
},
"1" : {
"analyticsLabel" : "Gender",
"analyticsName" : "male",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "7"
},
"50000147" : {
"analyticsOUname" : "Personnel Administration (D)",
"analyticsValue" : "3"
},
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "4"
},
},
},
"RACENAME" : {
"Unknown" : {
"analyticsLabel" : "Race",
"analyticsName" : "Unknown",
},
"Asian" : {
"analyticsLabel" : "Race",
"analyticsName" : "Asian",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "1"
},
},
"American Indian" : {
"analyticsLabel" : "Race",
"analyticsName" : "American Indian",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "1"
},
},
}
};
正如你所看到的,在种族->未知部分,它并不是通过应用模板模式"buildAnalyticsTableCountLevel"来完成的,所以我从来没有得到ORGUNIID信息,这对我正在做的事情非常重要。
不幸的是,我无法编辑即将到来的xml,因为这是各种项目中使用的更大框架的一部分,我无法更改它。所以我必须处理我得到的。
我尝试在xsl:key中使用string()方法,但这会使情况变得更糟。如有任何提示或帮助,我们将不胜感激。提前感谢!
更改样式表的开头,如下所示:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my">
<xsl:output method="text"/>
<my:unknown>Unknown</my:unknown>
并将其中一个key
定义更改为:
<xsl:key name="RACENAME_merge" match="detail/record"
use="concat((field[@name='RACENAME']
|document('')/*/my:unknown[not(field[@name='RACENAME'])]),
'|', field[@name='ORGUNITID'])" />
最后,将其中一个xsl:apply-templaes
更改为:
<xsl:apply-templates mode="buildAnalyticsTableCountLevel"
select="key($keyName, field[@name=$keyName])
[generate-id()=generate-id(key(concat($keyName, '_merge'),
concat((field[@name=$keyName]
|document('')/*/my:unknown[not(current()/field[@name='RACENAME'])]),
'|', field[@name=$ouIdFieldName])))]">
<xsl:with-param name="countField" select="$countField"/>
</xsl:apply-templates>
这些更改后的完整代码变为:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my">
<xsl:output method="text"/>
<my:unknown>Unknown</my:unknown>
<!-- Start external variables -->
<!-- Field names -->
<xsl:variable name="ageFieldName" select="'AGERANGEID'" />
<xsl:variable name="genderFieldName" select="'GENDER'" />
<xsl:variable name="raceFieldName" select="'RACENAME'" />
<xsl:variable name="ouIdFieldName" select="'ORGUNITID'" />
<xsl:variable name="ouNameFieldName" select="'ORGUNITNAME'" />
<!-- Keys -->
<xsl:key use="field[@name='AGERANGEID']" name="AGERANGEID" match="detail/record" />
<xsl:key use="concat(field[@name='AGERANGEID'],'|', field[@name='ORGUNITID'])" name="AGERANGEID_merge" match="detail/record" />
<xsl:key use="field[@name='GENDER']" name="GENDER" match="detail/record" />
<xsl:key use="concat(field[@name='GENDER'],'|', field[@name='ORGUNITID'])" name="GENDER_merge" match="detail/record" />
<xsl:key use="field[@name='RACENAME']" name="RACENAME" match="detail/record" />
<xsl:key use="concat((field[@name='RACENAME']
|document('')/*/my:unknown[not(current()/field[@name='RACENAME'])]),
'|', field[@name='ORGUNITID'])"
name="RACENAME_merge" match="detail/record" />
<xsl:key use="field[@name='ORGUNITID']" name="ORGUNITID" match="detail/record" />
<xsl:template match="/">
var analyticsMap = {<xsl:call-template name="buildAnalyticsTable" />};
</xsl:template>
<xsl:template name="buildAnalyticsTable">
<!-- Age -->
"<xsl:value-of select="$ageFieldName"/>" : {
<xsl:apply-templates mode="buildAnalyticsTableRangeLevel" select="//detail/record[generate-id()=generate-id(key($ageFieldName, field[@name=$ageFieldName]))]">
<xsl:with-param name="keyName" select="$ageFieldName"/>
<xsl:with-param name="countField" select="'NUMOFCOUNTAGE'"/>
<xsl:with-param name="label" select="'Age Range'" />
<xsl:with-param name="isGender" select="'false'" />
</xsl:apply-templates>
},
<!-- Gender -->
"<xsl:value-of select="$genderFieldName"/>" : {
<xsl:apply-templates mode="buildAnalyticsTableRangeLevel" select="//detail/record[generate-id()=generate-id(key($genderFieldName, field[@name=$genderFieldName]))]">
<xsl:with-param name="keyName" select="$genderFieldName"/>
<xsl:with-param name="countField" select="'NUMOFGENDERCOUNT'"/>
<xsl:with-param name="label" select="'Gender'" />
<xsl:with-param name="isGender" select="'true'" />
</xsl:apply-templates>
},
<!-- Race -->
"<xsl:value-of select="$raceFieldName"/>" : {
<xsl:apply-templates mode="buildAnalyticsTableRangeLevel" select="//detail/record[generate-id()=generate-id(key($raceFieldName, field[@name=$raceFieldName]))]">
<xsl:with-param name="keyName" select="$raceFieldName"/>
<xsl:with-param name="countField" select="'NUMOFRACE'"/>
<xsl:with-param name="label" select="'Race'" />
<xsl:with-param name="isGender" select="'true'" />
</xsl:apply-templates>
}
</xsl:template>
<xsl:template match="detail/record" mode="buildAnalyticsTableRangeLevel">
<xsl:param name="keyName" />
<xsl:param name="countField" />
<xsl:param name="label" />
<xsl:param name="isGender" />
<xsl:variable name="value" >
<xsl:call-template name="testForUnknown">
<xsl:with-param name="name" select="field[@name=$keyName]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="name">
<xsl:call-template name="testForGender">
<xsl:with-param name="isGender" select="$isGender"/>
<xsl:with-param name="name" select="$value"/>
</xsl:call-template>
</xsl:variable>
"<xsl:value-of select="$value"/>" : {
"analyticsLabel" : "<xsl:value-of select="$label"/>",
"analyticsName" : "<xsl:value-of select="$name"/>",
<xsl:apply-templates mode="buildAnalyticsTableCountLevel"
select="key($keyName, field[@name=$keyName])
[generate-id()=generate-id(key(concat($keyName, '_merge'),
concat((field[@name=$keyName]
|document('')/*/my:unknown[not(current()/field[@name='RACENAME'])]),
'|', field[@name=$ouIdFieldName])))]">
<xsl:with-param name="countField" select="$countField"/>
</xsl:apply-templates>
},
</xsl:template>
<xsl:template match="detail/record" mode="buildAnalyticsTableCountLevel">
<xsl:param name="countField" />
"<xsl:value-of select="field[@name=$ouIdFieldName]"/>" : {
"analyticsOUname" : "<xsl:value-of select="field[@name=$ouNameFieldName]"/>",
"analyticsValue" : "<xsl:value-of select="field[@name=$countField]"/>"
},
</xsl:template>
<xsl:template name="testForUnknown">
<xsl:param name="name" />
<xsl:choose>
<xsl:when test="string-length($name) = 0">
<xsl:value-of select="'Unknown'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$name" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="testForGender">
<xsl:param name="isGender" />
<xsl:param name="name" />
<xsl:choose>
<xsl:when test="$isGender = 'true' and $name = 1">
<xsl:value-of select="'male'" />
</xsl:when>
<xsl:when test="$isGender = 'true' and $name = 2">
<xsl:value-of select="'female'" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$name" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
当此转换应用于所提供的XML文档时:
<cds>
<sections>
<section name="myteam_CurrentAgeCompleteSection" link="false">
<detail name="">
<record>
<field name="AGERANGEID">30-39</field>
<field name="NUMOFCOUNTAGE">1</field>
<field name="ORGUNITID">00001001</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITNAME">Human Resources</field>
</record>
<record>
<field name="AGERANGEID">>=70</field>
<field name="NUMOFCOUNTAGE">5</field>
<field name="ORGUNITID">00001001</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITNAME">Human Resources</field>
</record>
</detail>
</section>
<section name="myteam_CurrentGenderCompleteSection" link="false">
<detail name="">
<record>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="ORGUNITNAME">Human Resources</field>
<field name="NUMOFGENDERCOUNT">5</field>
<field name="GENDER">2</field>
</record>
<record>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="ORGUNITNAME">Human Resources</field>
<field name="NUMOFGENDERCOUNT">7</field>
<field name="GENDER">1</field>
</record>
</detail>
</section>
<section name="myteam_CurrentRaceCompleteSection" link="false">
<detail name="">
<record>
<field name="ORGUNITNAME">Human Resources</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="NUMOFRACE">10.0</field>
<field name="RACENAME" />
</record>
<record>
<field name="ORGUNITNAME">Human Resources</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="NUMOFRACE">1</field>
<field name="RACENAME">Asian</field>
</record>
<record>
<field name="ORGUNITNAME">Human Resources</field>
<field name="PARENTORGUNITID">00000100</field>
<field name="ORGUNITID">00001001</field>
<field name="NUMOFRACE">1</field>
<field name="RACENAME">American Indian</field>
</record>
</detail>
</section>
<section name="myteam_ChildAgeColumnSection" link="false">
<detail name="">
<record>
<field name="AGERANGEID">40-49</field>
<field name="NUMOFCOUNTAGE">1</field>
<field name="ORGUNITID">50000013</field>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
</record>
<record>
<field name="AGERANGEID">50-59</field>
<field name="NUMOFCOUNTAGE">2</field>
<field name="ORGUNITID">50000013</field>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
</record>
<record>
<field name="AGERANGEID">>=70</field>
<field name="NUMOFCOUNTAGE">5</field>
<field name="ORGUNITID">50000013</field>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
</record>
</detail>
</section>
<section name="myteam_ChildGenderColumnSection" link="false">
<detail name="">
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">2</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000147</field>
<field name="ORGUNITNAME">Personnel Administration (D)</field>
<field name="NUMOFGENDERCOUNT">3</field>
<field name="GENDER">1</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">1</field>
</record>
</detail>
</section>
<section name="myteam_ChildGenderColumnSection" link="false">
<detail name="">
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">2</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000147</field>
<field name="ORGUNITNAME">Personnel Administration (D)</field>
<field name="NUMOFGENDERCOUNT">3</field>
<field name="GENDER">1</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">1</field>
</record>
</detail>
</section>
<section name="myteam_ChildGenderColumnSection" link="false">
<detail name="">
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000013</field>
<field name="ORGUNITNAME">IT computer center (D)</field>
<field name="NUMOFGENDERCOUNT">4</field>
<field name="GENDER">2</field>
</record>
<record>
<field name="PARENTORGUNITID">00001001</field>
<field name="ORGUNITID">50000147</field>
<field name="ORGUNITNAME">Personnel Administration (D)</field>
<field name="NUMOFGENDERCOUNT">3</field>
<field name="GENDER">1</field>
</record>
</detail>
</section>
</sections>
</cds>
生成所需的正确结果:
var analyticsMap = {
"AGERANGEID" : {
"30-39" : {
"analyticsLabel" : "Age Range",
"analyticsName" : "30-39",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "1"
},
},
">=70" : {
"analyticsLabel" : "Age Range",
"analyticsName" : ">=70",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "5"
},
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "5"
},
},
"40-49" : {
"analyticsLabel" : "Age Range",
"analyticsName" : "40-49",
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "1"
},
},
"50-59" : {
"analyticsLabel" : "Age Range",
"analyticsName" : "50-59",
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "2"
},
},
},
"GENDER" : {
"2" : {
"analyticsLabel" : "Gender",
"analyticsName" : "female",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "5"
},
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "4"
},
},
"1" : {
"analyticsLabel" : "Gender",
"analyticsName" : "male",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "7"
},
"50000147" : {
"analyticsOUname" : "Personnel Administration (D)",
"analyticsValue" : "3"
},
"50000013" : {
"analyticsOUname" : "IT computer center (D)",
"analyticsValue" : "4"
},
},
},
"RACENAME" : {
"Unknown" : {
"analyticsLabel" : "Race",
"analyticsName" : "Unknown",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "10.0"
},
},
"Asian" : {
"analyticsLabel" : "Race",
"analyticsName" : "Asian",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "1"
},
},
"American Indian" : {
"analyticsLabel" : "Race",
"analyticsName" : "American Indian",
"00001001" : {
"analyticsOUname" : "Human Resources",
"analyticsValue" : "1"
},
},
}
};