寻找一些想法-我有以下示例XML记录:
<?xml version="1.0"?>
<bdems:bulkDataRecord xmlns:bdems="http://www.imsglobal.org/services/lis/bdemsv1p0/imsbdemsFileData_v1p0">
<bdems:transactionRecord>
<bdems:transactionOpIdentifier>3064476-C-001355-01-2187-I0001</bdems:transactionOpIdentifier>
<bdems:serviceName>cmsv1p0</bdems:serviceName>
<bdems:interfaceName>sectionassociationmanager</bdems:interfaceName>
<bdems:operationName>replaceSectionAssociation</bdems:operationName>
<bdems:parameterSet>
<bdems:parameterRecord>
<bdems:parameterInvoc>In</bdems:parameterInvoc>
<bdems:parameterName>sourcedId</bdems:parameterName>
<bdems:parameterType>GUID</bdems:parameterType>
<bdems:parameterValue>
<bdems:guid>001355-01-2187-I0001</bdems:guid>
</bdems:parameterValue>
</bdems:parameterRecord>
<bdems:parameterRecord>
<bdems:parameterInvoc>In</bdems:parameterInvoc>
<bdems:parameterName>sectionAssociationRecord</bdems:parameterName>
<bdems:parameterType>SectionAssociationRecord</bdems:parameterType>
<bdems:parameterValue>
<cms:sectionAssociationRecord xmlns:cms="http://www.imsglobal.org/services/lis/cmsv1p0/imscms_v1p0">
<cms:sourcedGUID>
<cms:refAgentInstanceID>CS</cms:refAgentInstanceID>
<cms:sourcedId>001355-01-2187-I0001</cms:sourcedId>
</cms:sourcedGUID>
<cms:sectionAssociation>
<cms:status>Active</cms:status>
<cms:courseSectionIdList>
<cms:courseSectionId>001355-01-2187-1-01-02642</cms:courseSectionId>
<cms:courseSectionId>001355-01-2187-1-05-04486</cms:courseSectionId>
</cms:courseSectionIdList>
<cms:dataSource>CS</cms:dataSource>
<cms:extension>
<cms:extensionNameVocabulary>http://www.oracle.com/Enterprise/HCM/cmsv2p0/extensionnamevocabularyv1p0</cms:extensionNameVocabulary>
<cms:extensionTypeVocabulary>http://www.imsglobal.org/lis/cmsv1p0/extensionvocabularyv1p0</cms:extensionTypeVocabulary>
<cms:extensionField>
<cms:fieldName>Mode</cms:fieldName>
<cms:fieldType>String</cms:fieldType>
<cms:fieldValue>C</cms:fieldValue>
</cms:extensionField>
</cms:extension>
</cms:sectionAssociation>
</cms:sectionAssociationRecord>
</bdems:parameterValue>
</bdems:parameterRecord>
</bdems:parameterSet>
</bdems:transactionRecord>
</bdems:bulkDataRecord>
我正在尝试使用以下xsl将其解析为一个更加用户友好的文件。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bdems="http://www.imsglobal.org/services/lis/bdemsv1p0/imsbdemsFileData_v1p0" xmlns:cms="http://www.imsglobal.org/services/lis/cmsv1p0/imscms_v1p0">
<xsl:template match="/">
<combinations>
<xsl:for-each select="//bdems:transactionRecord">
<combination>
<xsl:attribute name="id"> <xsl:value-of select="bdems:transactionOpIdentifier" /> </xsl:attribute>
<id><xsl:value-of select="bdems:transactionOpIdentifier" /></id>
<xsl:for-each select="bdems:parameterSet/bdems:parameterRecord">
<xsl:if test="bdems:parameterName = 'sectionAssociationRecord'">
<courses>
<xsl:for-each select="bdems:parameterValue/cms:sectionAssociationRecord/cms:sectionAssociation">
<xsl:if test="cms:status = 'Active'">
<xsl:for-each select="cms:courseSectionIdList">
<course><xsl:value-of select="cms:courseSectionId" /></course>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</courses>
</xsl:if>
</xsl:for-each>
</combination>
</xsl:for-each>
</combinations>
</xsl:template>
</xsl:stylesheet>
一切正常,除了只从cms:courseSectionId中提取第一条记录。
关于我为什么只获得第一张唱片的任何想法?
当前输出:
<?xml version="1.0"?>
<combinations xmlns:bdems="http://www.imsglobal.org/services/lis/bdemsv1p0/imsbdemsFileData_v1p0" xmlns:cms="http://www.imsglobal.org/services/lis/cmsv1p0/imscms_v1p0">
<combination id="3064476-C-001355-01-2187-I0001">
<id>3064476-C-001355-01-2187-I0001</id>
<courses>
<course>001355-01-2187-1-01-02642</course>
</courses>
</combination>
</combinations>
答案 0 :(得分:0)
您每人的最后一个在courseSectionList上。只有一个列表,其中包含多个courseSectionId。如果将每个选择更改为courseSectionId,它将起作用。
我测试了更改,得到了以下XSLT
SELECT ... FROM ...