MarkLogic cts的问题:element-values()

时间:2018-01-22 15:49:20

标签: xquery marklogic

我有20000个文档,每个文档中包含50多个元素。我想要其中一个元素的值,所以这占了20000个值。

"问题"它们都是相同的值,因为testdata。现在,当我在一个元素上运行cts:element-values()时,它给了我两个值。这不是我想要的,我希望所有20000都在我的屏幕上。

我添加了范围元素idex,这是搜索所需要的。这是我正在运行的查询。

declare namespace xbrli="http://www.xbrl.org/2003/instance";    
declare namespace venj-bw2-i="http://www.nltaxonomie.nl/nt11/venj/20161214/dictionary/venj-bw2-data";
    let $facts :=
    let $searchNode := "venj-bw2-i:Income"
    let $searchNode2 := "venj-bw2-i:AssetsNoncurrent"
      return cts:element-values(xs:QName($searchNode))

    return $facts

并返回值

300000和310000

使用以下方法添加文档:

for $i in 1 to 20000
return
  xdmp:document-insert(fn:concat("document", $i, ".xml"), 
<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xml:lang="nl" xmlns:kvk-i="http://www.nltaxonomie.nl/nt11/kvk/20161214/dictionary/kvk-data" xmlns:venj-bw2-dm="http://www.nltaxonomie.nl/nt11/venj/20161214/dictionary/venj-bw2-domains" 
xmlns:venj-bw2-i="http://www.nltaxonomie.nl/nt11/venj/20161214/dictionary/venj-bw2-data" xmlns:rj-i="http://www.nltaxonomie.nl/nt11/rj/20161214/dictionary/rj-data" xmlns:rj-t="http://www.nltaxonomie.nl/nt11/rj/20161214/dictionary/rj-tuples" xmlns:kvk-t="http://www.nltaxonomie.nl/nt11/kvk/20161214/dictionary/kvk-tuples"  xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:nl-cd="http://www.nltaxonomie.nl/nt11/sbr/20160610/dictionary/nl-common-data" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:venj-bw2-dim="http://www.nltaxonomie.nl/nt11/venj/20161214/dictionary/venj-bw2-axes">

    <link:schemaRef xlink:type="simple" xlink:href="http://www.nltaxonomie.nl/nt11/kvk/20161214/entrypoints/kvk-rpt-jaarverantwoording-2016-nlgaap-micro.xsd"/>

    <xbrli:context id="FY16d_ManagingOrSupervisoryDirector_Typed_1">
        <xbrli:entity>
            <xbrli:identifier scheme="http://www.kvk.nl/kvk-id">{$i}</xbrli:identifier>
        </xbrli:entity>
        <xbrli:period>
            <xbrli:startDate>2016-01-01</xbrli:startDate>
            <xbrli:endDate>2016-12-31</xbrli:endDate>
        </xbrli:period>
        <xbrli:scenario>
            <xbrldi:typedMember dimension="venj-bw2-dim:ManagingOrSupervisoryDirectorNamesAxis">
                <venj-bw2-dm:ManagingOrSupervisoryDirectorTypedMember>Frank Jensen</venj-bw2-dm:ManagingOrSupervisoryDirectorTypedMember>
            </xbrldi:typedMember>
        </xbrli:scenario>
    </xbrli:context>
    <xbrli:context id="FY16d">
        <xbrli:entity>
            <xbrli:identifier scheme="http://www.kvk.nl/kvk-id">{$i}</xbrli:identifier>
        </xbrli:entity>
        <xbrli:period>
            <xbrli:startDate>2016-01-01</xbrli:startDate>
            <xbrli:endDate>2016-12-31</xbrli:endDate>
        </xbrli:period>
    </xbrli:context>
    <xbrli:context id="FY16d_Commercial_Separate">
        <xbrli:entity>
            <xbrli:identifier scheme="http://www.kvk.nl/kvk-id">{$i}</xbrli:identifier>
        </xbrli:entity>
        <xbrli:period>
            <xbrli:startDate>2016-01-01</xbrli:startDate>
            <xbrli:endDate>2016-12-31</xbrli:endDate>
        </xbrli:period>
        <xbrli:scenario>
            <xbrldi:explicitMember dimension="venj-bw2-dim:BasisOfPreparationAxis">venj-bw2-dm:CommercialMember</xbrldi:explicitMember>
            <xbrldi:explicitMember dimension="venj-bw2-dim:FinancialStatementsTypeAxis">venj-bw2-dm:SeparateMember</xbrldi:explicitMember>
        </xbrli:scenario>
    </xbrli:context>
    <xbrli:context id="FY16i_Commercial_Separate">
        <xbrli:entity>
            <xbrli:identifier scheme="http://www.kvk.nl/kvk-id">{$i}</xbrli:identifier>
        </xbrli:entity>
        <xbrli:period>
            <xbrli:instant>2016-12-31</xbrli:instant>
        </xbrli:period>
        <xbrli:scenario>
            <xbrldi:explicitMember dimension="venj-bw2-dim:BasisOfPreparationAxis">venj-bw2-dm:CommercialMember</xbrldi:explicitMember>
            <xbrldi:explicitMember dimension="venj-bw2-dim:FinancialStatementsTypeAxis">venj-bw2-dm:SeparateMember</xbrldi:explicitMember>
        </xbrli:scenario>
    </xbrli:context>
    <xbrli:context id="FY15i_Commercial_Separate">
        <xbrli:entity>
            <xbrli:identifier scheme="http://www.kvk.nl/kvk-id">{$i}</xbrli:identifier>
        </xbrli:entity>
        <xbrli:period>
            <xbrli:instant>2015-12-31</xbrli:instant>
        </xbrli:period>
        <xbrli:scenario>
            <xbrldi:explicitMember dimension="venj-bw2-dim:BasisOfPreparationAxis">venj-bw2-dm:CommercialMember</xbrldi:explicitMember>
            <xbrldi:explicitMember dimension="venj-bw2-dim:FinancialStatementsTypeAxis">venj-bw2-dm:SeparateMember</xbrldi:explicitMember>
        </xbrli:scenario>
    </xbrli:context>
    <xbrli:context id="FY15d_Commercial_Separate">
        <xbrli:entity>
            <xbrli:identifier scheme="http://www.kvk.nl/kvk-id">{$i}</xbrli:identifier>
        </xbrli:entity>
        <xbrli:period>
            <xbrli:startDate>2015-01-01</xbrli:startDate>
            <xbrli:endDate>2015-12-31</xbrli:endDate>
        </xbrli:period>
        <xbrli:scenario>
            <xbrldi:explicitMember dimension="venj-bw2-dim:BasisOfPreparationAxis">venj-bw2-dm:CommercialMember</xbrldi:explicitMember>
            <xbrldi:explicitMember dimension="venj-bw2-dim:FinancialStatementsTypeAxis">venj-bw2-dm:SeparateMember</xbrldi:explicitMember>
        </xbrli:scenario>
    </xbrli:context>

    <xbrli:unit id="EUR">
        <xbrli:measure>iso4217:EUR</xbrli:measure>
    </xbrli:unit>

    <kvk-t:ContactForDocumentPresentation>
        <kvk-i:ContactType contextRef="FY16d">Intermediair</kvk-i:ContactType>
        <nl-cd:FirstName contextRef="FY16d">Karel</nl-cd:FirstName>
        <nl-cd:FamilyName contextRef="FY16d">Broekhuis</nl-cd:FamilyName>
        <kvk-i:OrganisationName contextRef="FY16d">Broekhuis Accountants en Adviseurs BV</kvk-i:OrganisationName>
        <nl-cd:TelephoneNumber contextRef="FY16d">01045655281</nl-cd:TelephoneNumber>
        <nl-cd:EmailAddressFull contextRef="FY16d">Karel@Broekhuis.com</nl-cd:EmailAddressFull>
    </kvk-t:ContactForDocumentPresentation>

<rj-t:EntityAddressPresentation>
        <nl-cd:StreetNameNL contextRef="FY16d">Noordeinde</nl-cd:StreetNameNL>
        <nl-cd:HouseNumberNL contextRef="FY16d">68</nl-cd:HouseNumberNL>
        <nl-cd:PostalCodeNL contextRef="FY16d">2514GL</nl-cd:PostalCodeNL>
        <nl-cd:PlaceOfResidenceNL contextRef="FY16d">Den Haag</nl-cd:PlaceOfResidenceNL>
    </rj-t:EntityAddressPresentation>

    <kvk-i:LegalSizeCriteriaClassification contextRef="FY16d">Micro</kvk-i:LegalSizeCriteriaClassification>

    <venj-bw2-i:LegalEntityName contextRef="FY16d">BAA BV</venj-bw2-i:LegalEntityName>
    <venj-bw2-i:LegalEntityLegalForm contextRef="FY16d">Besloten vennootschap met beperkte aansprakelijkheid</venj-bw2-i:LegalEntityLegalForm>
    <venj-bw2-i:LegalEntityRegisteredOffice contextRef="FY16d">Den Haag</venj-bw2-i:LegalEntityRegisteredOffice>
    <venj-bw2-i:ChamberOfCommerceRegistrationNumber contextRef="FY16d">30267975</venj-bw2-i:ChamberOfCommerceRegistrationNumber>

    <venj-bw2-i:FinancialReportingPeriodCurrentStartDate contextRef="FY16d">2016-01-01</venj-bw2-i:FinancialReportingPeriodCurrentStartDate>
    <venj-bw2-i:FinancialReportingPeriodCurrentEndDate contextRef="FY16d">2016-12-31</venj-bw2-i:FinancialReportingPeriodCurrentEndDate>


    <venj-bw2-i:DocumentAdoptionStatus contextRef="FY16d">Nee</venj-bw2-i:DocumentAdoptionStatus>

    <venj-bw2-i:FinancialReportingPeriodPreviousStartDate contextRef="FY16d">2015-01-01</venj-bw2-i:FinancialReportingPeriodPreviousStartDate>
    <venj-bw2-i:FinancialReportingPeriodPreviousEndDate contextRef="FY16d">2015-12-31</venj-bw2-i:FinancialReportingPeriodPreviousEndDate>
    <rj-i:FinancialReportingPeriodDifferentThanAnnualStatus contextRef="FY16d">Nee</rj-i:FinancialReportingPeriodDifferentThanAnnualStatus>

    <rj-i:DocumentPresentationCurrency contextRef="FY16d">EUR</rj-i:DocumentPresentationCurrency>

    <venj-bw2-i:BasisOfPreparation contextRef="FY16d">Commercieel</venj-bw2-i:BasisOfPreparation>

    <venj-bw2-i:BalanceSheetBeforeAfterAppropriationResults contextRef="FY16d_Commercial_Separate">Na</venj-bw2-i:BalanceSheetBeforeAfterAppropriationResults>
    <venj-bw2-i:BalanceSheetBeforeAfterAppropriationResults contextRef="FY15d_Commercial_Separate">Na</venj-bw2-i:BalanceSheetBeforeAfterAppropriationResults>

    <venj-bw2-i:CostsIncorporationShareIssue contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">150000</venj-bw2-i:CostsIncorporationShareIssue>
    <venj-bw2-i:AssetsNoncurrent  contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">150000</venj-bw2-i:AssetsNoncurrent>  
    <venj-bw2-i:CalledUpShareCapital contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">50000</venj-bw2-i:CalledUpShareCapital>
    <venj-bw2-i:AssetsCurrent contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">50000</venj-bw2-i:AssetsCurrent>
    <venj-bw2-i:Assets contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">200000</venj-bw2-i:Assets>
    <venj-bw2-i:Equity contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">100000</venj-bw2-i:Equity>
    <venj-bw2-i:Provisions contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">25000</venj-bw2-i:Provisions>
    <venj-bw2-i:Liabilities contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">75000</venj-bw2-i:Liabilities>
    <venj-bw2-i:EquityAndLiabilities contextRef="FY16i_Commercial_Separate" unitRef="EUR" decimals="INF">200000</venj-bw2-i:EquityAndLiabilities>   

    <venj-bw2-i:CostsIncorporationShareIssue contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">140000</venj-bw2-i:CostsIncorporationShareIssue>
    <venj-bw2-i:AssetsNoncurrent  contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">140000</venj-bw2-i:AssetsNoncurrent>
    <venj-bw2-i:CalledUpShareCapital contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">60000</venj-bw2-i:CalledUpShareCapital>
    <venj-bw2-i:AssetsCurrent contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">60000</venj-bw2-i:AssetsCurrent>
    <venj-bw2-i:Assets contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">200000</venj-bw2-i:Assets>
    <venj-bw2-i:Equity contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">100000</venj-bw2-i:Equity>
    <venj-bw2-i:Provisions contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">35000</venj-bw2-i:Provisions>
    <venj-bw2-i:Liabilities contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">65000</venj-bw2-i:Liabilities>  
    <venj-bw2-i:EquityAndLiabilities contextRef="FY15i_Commercial_Separate" unitRef="EUR" decimals="INF">200000</venj-bw2-i:EquityAndLiabilities>

    <venj-bw2-i:NetRevenue contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">200000</venj-bw2-i:NetRevenue>
    <venj-bw2-i:OperatingIncomeOther contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">80000</venj-bw2-i:OperatingIncomeOther>
    <venj-bw2-i:IncomeOther contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">30000</venj-bw2-i:IncomeOther>
    <venj-bw2-i:Income contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">310000</venj-bw2-i:Income>
    <venj-bw2-i:WagesSalaries contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">80000</venj-bw2-i:WagesSalaries>
    <venj-bw2-i:DepreciationAmortisationAndDecreaseInValueAssets contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">10000</venj-bw2-i:DepreciationAmortisationAndDecreaseInValueAssets>
    <venj-bw2-i:OperatingExpensesOther contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">10000</venj-bw2-i:OperatingExpensesOther>
    <venj-bw2-i:ExpensesOther contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">5000</venj-bw2-i:ExpensesOther>
    <venj-bw2-i:CostsRawMaterialsConsumables contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">5000</venj-bw2-i:CostsRawMaterialsConsumables>
    <venj-bw2-i:Expenses contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">110000</venj-bw2-i:Expenses>
    <venj-bw2-i:ResultBeforeTax contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">200000</venj-bw2-i:ResultBeforeTax>
    <venj-bw2-i:IncomeTaxExpense contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">100000</venj-bw2-i:IncomeTaxExpense>
    <venj-bw2-i:ResultAfterTax contextRef="FY16d_Commercial_Separate" unitRef="EUR" decimals="INF">100000</venj-bw2-i:ResultAfterTax>

    <venj-bw2-i:NetRevenue contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">180000</venj-bw2-i:NetRevenue>
    <venj-bw2-i:OperatingIncomeOther contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">100000</venj-bw2-i:OperatingIncomeOther>
    <venj-bw2-i:IncomeOther contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">20000</venj-bw2-i:IncomeOther>
    <venj-bw2-i:Income contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">300000</venj-bw2-i:Income>
    <venj-bw2-i:WagesSalaries contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">80000</venj-bw2-i:WagesSalaries>
    <venj-bw2-i:DepreciationAmortisationAndDecreaseInValueAssets contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">5000</venj-bw2-i:DepreciationAmortisationAndDecreaseInValueAssets>
    <venj-bw2-i:OperatingExpensesOther contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">15000</venj-bw2-i:OperatingExpensesOther>
    <venj-bw2-i:ExpensesOther contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">5500</venj-bw2-i:ExpensesOther>
    <venj-bw2-i:CostsRawMaterialsConsumables contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">5500</venj-bw2-i:CostsRawMaterialsConsumables>
    <venj-bw2-i:Expenses contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">111000</venj-bw2-i:Expenses>
    <venj-bw2-i:ResultBeforeTax contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">189000</venj-bw2-i:ResultBeforeTax>
    <venj-bw2-i:IncomeTaxExpense contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">100000</venj-bw2-i:IncomeTaxExpense>
    <venj-bw2-i:ResultAfterTax contextRef="FY15d_Commercial_Separate" unitRef="EUR" decimals="INF">89000</venj-bw2-i:ResultAfterTax>

    <venj-bw2-i:DirectorType contextRef="FY16d_ManagingOrSupervisoryDirector_Typed_1">Bestuurder (huidig)</venj-bw2-i:DirectorType>
    <venj-bw2-i:DirectorSignedStatus contextRef="FY16d_ManagingOrSupervisoryDirector_Typed_1">Nee</venj-bw2-i:DirectorSignedStatus>
    <venj-bw2-i:DirectorReasonNoSignature contextRef="FY16d_ManagingOrSupervisoryDirector_Typed_1">De jaarrekening is nog niet vastgesteld</venj-bw2-i:DirectorReasonNoSignature>
    </xbrli:xbrl>,
    <options xmlns="xdmp:document-insert">
  <permissions>{xdmp:default-permissions()}</permissions>
      <collections>{
        <collection>semansysdocs</collection>
      }</collections>
    </options> 
)

如果我想要那些20000值,你知道我需要运行哪个功能吗?

1 个答案:

答案 0 :(得分:5)

cts:element-valuescts:values()等类似函数旨在为您返回唯一值,因此您不会返回重复项。您可以使用cts:search()fn:collection()迭代所有文件,但您也可以根据频率重复这些值,但不确定实际用途是什么。但仍有一些代码:

for $v in cts:element-values(xs:QName("venj-bw2-i:Income"))
for $i in (1 to cts:frequency($v))
return $v

您确定需要像这样重复所有值吗?仅以频率列出值可能就足够了:

for $v in cts:element-values(xs:QName("venj-bw2-i:Income"))
return $v || " - " || cts:frequency($v)

HTH!