How to access schema element annotation using Marklogic sc:annotations method

Lone Sloane

Given the following schema

<?xml version="1.0" encoding="UTF-8"?>
<?xdmp-annotations all?> <!-- Preserve documentation annotations -->
<xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    elementFormDefault="qualified"
    targetNamespace="http://my-namespace/graphql" 
    xmlns:gql="http://my-namespace/graphql">

    <xs:complexType name="Person">
        <xs:choice maxOccurs="unbounded">
            <xs:element name="name" type="xs:string" minOccurs="1"/>
            <xs:element name="height" type="xs:string" minOccurs="0"/>
            <xs:element name="appearsIn" type="xs:string" minOccurs="0"/>
            <xs:element name="friends">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="person" type="gql:Person" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:choice>
    </xs:complexType>

    <xs:element name='person' type='gql:Person'>
        <xs:annotation>
            <xs:documentation>
            Person interface
            </xs:documentation>
        </xs:annotation>
    </xs:element>

</xs:schema>      

how would I access the "person" element documentation?

The following code returns nothing:

xquery version "1.0-ml";

import schema namespace gql ="http://my-namespace/graphql" at "/graphql/person.xsd";

let $element := element {xs:QName('gql:person')} {}
return 
<xml>
  {sc:element-decl($element) => sc:annotations()}
</xml>

According to the documentation, the processing instruction "<?xdmp-annotations all?>" should be enough to ensure documentation is returned in addition to the appinfo, no?

mholstege

Two things:

  1. Your namespaces don't match between the schema and the query, so what happens is you get a dummy schema for the namespace and that doesn't have a specific element declaration so it get treated as anyType.
  2. You need to put the processing instruction inside the xs:schema element so that the schema parsing code sees it.

Fix those two things and your query works fine.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Marklogic sc : annotations 메서드를 사용하여 스키마 요소 주석에 액세스하는 방법

분류에서Dev

how to derive xml element name from an attribute value of a class using annotations?

분류에서Dev

how to validate telerik mvc grid using remote attribute in data annotations?

분류에서Dev

How to access an element in the structure which not the first - Qsort

분류에서Dev

How to search for one file in Marklogic

분류에서Dev

Can't properly access element using Python Selenium WebDriver

분류에서Dev

Java: Using a mutator method on element of array with a for loop, not working

분류에서Dev

Cannot Access Attach Method using SwiftMailer in Symfony 1.4

분류에서Dev

Creating Callables using Annotation

분류에서Dev

Schema Error, 'has no method save'

분류에서Dev

Qt: How to access an element dragged on the main window by its id?

분류에서Dev

Windows forms container : Panel, how to access an element at a particular index?

분류에서Dev

Why does the test pass when using the element? method to check the element's existence?

분류에서Dev

How to insert a new element after an element by using the selector

분류에서Dev

Marklogic 어휘집 : cts : element-value 이해

분류에서Dev

what is the use of schema-element and schema-attribute

분류에서Dev

How to find last occurrence of an element using FindLast()

분류에서Dev

How to select the specific element using HtmlUnit with java?

분류에서Dev

How to access already initialised node within another method SpriteKit

분류에서Dev

How to access a git repository using SSH?

분류에서Dev

How to access private variables using functions only

분류에서Dev

How to Django remote access to server using Windows

분류에서Dev

How to convert relational schema to Accumulo schema?

분류에서Dev

How to set the result code using setResult(); method

분류에서Dev

How to migrate table into schema

분류에서Dev

Can not find declaration of element 'xsd:schema'

분류에서Dev

Annotation - Enforce a square using imrect

분류에서Dev

Can't use annotation inside method

분류에서Dev

How to load multiple configuration file from classpath using @ImportResource annotation in Spring

Related 관련 기사

  1. 1

    Marklogic sc : annotations 메서드를 사용하여 스키마 요소 주석에 액세스하는 방법

  2. 2

    how to derive xml element name from an attribute value of a class using annotations?

  3. 3

    how to validate telerik mvc grid using remote attribute in data annotations?

  4. 4

    How to access an element in the structure which not the first - Qsort

  5. 5

    How to search for one file in Marklogic

  6. 6

    Can't properly access element using Python Selenium WebDriver

  7. 7

    Java: Using a mutator method on element of array with a for loop, not working

  8. 8

    Cannot Access Attach Method using SwiftMailer in Symfony 1.4

  9. 9

    Creating Callables using Annotation

  10. 10

    Schema Error, 'has no method save'

  11. 11

    Qt: How to access an element dragged on the main window by its id?

  12. 12

    Windows forms container : Panel, how to access an element at a particular index?

  13. 13

    Why does the test pass when using the element? method to check the element's existence?

  14. 14

    How to insert a new element after an element by using the selector

  15. 15

    Marklogic 어휘집 : cts : element-value 이해

  16. 16

    what is the use of schema-element and schema-attribute

  17. 17

    How to find last occurrence of an element using FindLast()

  18. 18

    How to select the specific element using HtmlUnit with java?

  19. 19

    How to access already initialised node within another method SpriteKit

  20. 20

    How to access a git repository using SSH?

  21. 21

    How to access private variables using functions only

  22. 22

    How to Django remote access to server using Windows

  23. 23

    How to convert relational schema to Accumulo schema?

  24. 24

    How to set the result code using setResult(); method

  25. 25

    How to migrate table into schema

  26. 26

    Can not find declaration of element 'xsd:schema'

  27. 27

    Annotation - Enforce a square using imrect

  28. 28

    Can't use annotation inside method

  29. 29

    How to load multiple configuration file from classpath using @ImportResource annotation in Spring

뜨겁다태그

보관