Hi Robby,

You get string since your function basictypes:getPackage() has return
type xs:string
(and according to the XQuery specification any element can be casted to
xs:string by getting it's text value). Try to change:

declare function basictypes:getPackage($*basictype* as element(Product)) as
xs:string

to the:

declare function basictypes:getPackage($*basictype* as element(Product)) as
element(Package)


Ivan Shcheklein,
Sedna Team


Hi all,
>
>
>
> I am encountering a strange issue while testing out custom xquery modules
> against sedna.
>
>
>
> I have 2 types of xml:
>
> ·         basictypes  (== product)
>
> ·          packages
>
> which from high level point of view look like
>
> -----------------------------------------------------------------
>
> <Product>
>
>   <ProductInformation>
>
>     <Name>PH3330L</Name>
>
>     <PackageID>SOT669</PackageID>
>
>   </ProductInformation>
>
> </Product>
>
> -----------------------------------------------------------------
>
> <Package>
>
>   <PackageInformation>
>
>     <Name>SOT669</Name>
>
>   </PackageInformation>
>
> </Package>
>
> -----------------------------------------------------------------
>
>
>
> *Basictype.xqlib*
>
> * *
>
> module *namespace* *basictypes* = "http://www.nxp.com/basictypes";;
>
> import module *namespace* packages= "http://www.nxp.com/packages";;
>
>
>
> declare function basictypes:getBasicTypes() as element(Product)* {
>
>     collection("basicTypes/released")/Product
>
> };
>
>
>
> declare function basictypes:getBasicType($id as xs:string) as
> element(Product) {
>
>     basictypes:getBasicTypes()[ProductInformation/Name/text() = $id]
>
> };
>
>
>
> declare function basictypes:getPackage($*basictype* as element(Product))
> as xs:string {
>
>     let $pkg_id := $*basictype*/ProductInformation/PackageID/text()
>
>     return packages:getPackage($pkg_id)
>
> };**
>
> * *
>
> *Package.xqlib*
>
> * *
>
> module *namespace* packages = "http://www.nxp.com/packages";;
>
>
>
> declare function packages:getPackages() as element(Package)* {
>
>     collection("packages/released")/Package
>
> };
>
>
>
> declare function packages:getPackage($id as xs:string) as element(Package)
> {
>
>     packages:getPackages()[PackageInformation/Name/text() = $id]
>
> };
>
>
>
>
>
> *Xquery 1:  works fine and returns <Package> xml*
>
>
>
> import module namespace packages= "http://www.nxp.com/packages";;
>
>
>
> let $package := packages:getPackage('SOT226')
>
> return $package
>
>
>
> *Xquery 2: returns contents of <Package> but not as xml but as
> concatenated text*
>
> * *
>
> import module namespace basictypes= "http://www.nxp.com/basictypes";;
>
> import module namespace packages= "http://www.nxp.com/packages";;
>
> let $basictype := basictypes:getBasicType('PH3330L')
>
> let $package := basictypes:getPackage($basictype)
>
> return $package
>
>
>
>
>
> It  looks like the result is not properly serialized between the 2 xquery
> modules but I have no clue if I’m making some xquery error or if this is
> sedna specific.
>
>
>
> Any  help is appreciated,
>
> Robby Pelssers
>
>
> ------------------------------------------------------------------------------
> EditLive Enterprise is the world's most technically advanced content
> authoring tool. Experience the power of Track Changes, Inline Image
> Editing and ensure content is compliant with Accessibility Checking.
> http://p.sf.net/sfu/ephox-dev2dev
> _______________________________________________
> Sedna-discussion mailing list
> Sedna-discussion@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sedna-discussion
>
>
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Sedna-discussion mailing list
Sedna-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to