[MarkLogic Dev General] Unable to get the value of Element Š.

Khan, Kashif Kashif.Khan at hmhco.com
Fri May 24 15:47:31 PDT 2013


Thanks for the suggestion.

Best Regards,
Kashif Khan

Sent from my iPhone

On May 24, 2013, at 6:42 PM, "David Lee" <David.Lee at marklogic.com<mailto:David.Lee at marklogic.com>> wrote:

> Yes I looked into that but the problem is that I can not use any MarkLogic functions.

Maybe this is a dumb question,  but if you cant use any marklogic functions why are you asking the question on a marklogic mailing list ?
If you want a pure XQuery answer I suggest the xquery-talk mailing list   talk at x-query.com<mailto:talk at x-query.com>





From: general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Khan, Kashif
Sent: Friday, May 24, 2013 6:39 PM
To: MarkLogic Developer Discussion
Cc: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Unable to get the value of Element Š.

Yes I looked into that but the problem is that I can not use any MarkLogic functions.
Best Regards,
Kashif Khan

Sent from my iPhone

On May 24, 2013, at 6:36 PM, "Danny Sokolsky" <Danny.Sokolsky at marklogic.com<mailto:Danny.Sokolsky at marklogic.com>> wrote:
Hi Kashif,

In that case, you can use xdmp:unquote, which parses a string as XML.  Something like:

let $document :=
"<report>
        <body>
        <row>
            <ChapterTitle>Front Matter</ChapterTitle>
</row>
</body>
</report>"
let $document2 := xdmp:unquote($document)
return $document2//ChapterTitle

From: general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Khan, Kashif
Sent: Friday, May 24, 2013 3:31 PM
To: MarkLogic Developer Discussion
Cc: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Unable to get the value of Element Š.

Danny I am trying to resolve a problem where I have to convert text string into the tag name and then use that to extract the value from the XML.
Best Regards,
Kashif Khan

Sent from my iPhone

On May 24, 2013, at 5:47 PM, "Danny Sokolsky" <Danny.Sokolsky at marklogic.com<mailto:Danny.Sokolsky at marklogic.com>> wrote:
Hi Kashif,

Why not treat your XML as XML instead of a string.  Then you can just use XPath.  Something like:

let $document :=
<report>
        <body>
        <row>
            <ChapterTitle>Front Matter</ChapterTitle>
</row>
</body>
</report>
return $document//ChapterTitle
=>
<ChapterTitle>Front Matter</ChapterTitle>

-Danny

From: general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com> [mailto:general-bounces at developer.marklogic.com] On Behalf Of Khan, Kashif
Sent: Friday, May 24, 2013 2:38 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Unable to get the value of Element Š.

Hello Everyone, I am having a problem extracting value from an element
Here is the XML on which I am trying to run my query


Let $document := "<report>
        <body>
        <row>
            <ChapterTitle>Front Matter</ChapterTitle>
</row

</body>

</report>"



These are the functions that I have written to extract the value of the "ChapterTitle" Tag



declare function oxy:getHierarchyElements() {


let $TagName := "Chapter Title"


        (:removing the space between Chapter and Title:)

let $tokenizedString := fn:tokenize(($TagName), '\s')
        let $concatString :=  fn:concat($tokenizedString[1], $tokenizedString[2])
         return
            element {$concatString} {''}

};

declare function oxy:getLevel($document as xs:string){
    let $file := doc($document)
    let $hierarchy := oxy:getHierarchyElements()
    return
            $file/report/body/row/$hierarchy
};



When I call oxy:getLevel($oxy:document) I get <ChapterTitle/>  instead of "Front Matter" from the XML file.



If I replace   $file/report/body/row/$hierarchy with  $file/report/body/row/ChapterTitle I get the correct value.



Thanks for your help in advance


————————————————
Kashif Khan
_______________________________________________
General mailing list
General at developer.marklogic.com<mailto:General at developer.marklogic.com>
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General at developer.marklogic.com<mailto:General at developer.marklogic.com>
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General at developer.marklogic.com<mailto:General at developer.marklogic.com>
http://developer.marklogic.com/mailman/listinfo/general
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20130524/23c72258/attachment-0001.html 


More information about the General mailing list