Domanda


I have a question regarding FLWOR joins. Here's an overview of how my XMLs look like.

<user>
  <user-id>...</user-id>
  <username>...</username>
  <password>...</password>
  <!-- By schema file, there could be unbounded role-ids -->
  <role-id>...</role-id>
  <role-id>...</role-id>
  <role-id>...</role-id>
</user>

<role>
  <role-id>...</role-id>
  <name>...</name>
  <!-- By schema file, there could be unbounded permission-ids -->
  <permission-id>...</permission-id>
  <permission-id>...</permission-id>
  <permission-id>...</permission-id>
</role>

<permission>
  <permission-id>...</permission-id>
  <resource-id>...</resource-id>
  <operation-id>...</operation-id>
</permission>

I have a FLWOR expression, query, which should return a sequence of permissions for a given user. It should be simple enough, however I can't figure out why I'm getting an empty ResourceSet every time run the query.

for $i in collection("data/rbac/users")/user[user-id="..."]/role-id
for $j in collection("data/rbac/roles")/roles/role
for $k in collection("data/rbac/permissions")/permission
where $i = $j/role-id and exists($j/permission-id[. = $k/permission-id])
return $k

Any suggestion is much appreciated. Thanks,

Igor

È stato utile?

Soluzione

It's hard to tell since the structure of the source XML data isn't completely clear. But there seems to be a small inconsistency - the second line of your XQuery assumes a node named roles inside your collection data/rbac/roles. Maybe the second line should look like

for $j in collection("data/rbac/roles")/role

? Just guessing...

Altri suggerimenti

Your XQuery does not seem to match the data you provide. For example role-id is not a child of user, and also there does not seem to be a roles element. This query given the provided XML will likely return an empty resource set.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top