This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

XQuery element names


Hello again Per.

So while I'm still somewhat interested in the XML syntax of my previous question, I've moved on to trying out Kawa-XQuery. It is working pretty well for me and the syntax is nice and terse, although I wish DSSSL had prevailed rather than XPath's funkiness and now XQuery's elaboration on it.

But I have a few questions/problems.

One is that I can't get node-name, name, element-name or whatever it is supposed to be called to give me an element name as a string.

My reading of the docs make me think I should be able to do this:

return <element name="{node-name($field)}" ...

But I always get unbound for node-name.

http://www.w3.org/TR/xquery-operators/#func-node-name

Also I'm having no luck specifying xmlns: for anything.

Once again, any tips greatly appreciated in advance!

jim
let $fields := 
<fields>
  <field name="f1_name"/>
  <field name="f2_sponsor" type="decimal"/>
  <field name="f3_trustees" maxOccurs="4"/>
</fields>
let $field_elements :=
  <sequence>
    {
      for $field in $fields/field 
        return <element name="{$field/@name}" 
                        type="{if ($field/@type) then $field/@type else "xsd:string"}"
                        minOccurs="{if ($field/@minOccurs) then $field/@minOccurs else "0"}"
                        maxOccurs="{if ($field/@maxOccurs) then $field/@maxOccurs else "1"}"
                        />
    }
  </sequence>
return 
  <schema 
     targetnamespace="http://com.stuarthack.com/schema/Sponsor";>
	<element name="Sponsor">
	   <complexType>
          {$field_elements}
       </complexType>
    </element>
  </schema>


let $fields := 
<fields>
  <f1_name/>
  <f2_sponsor/>
  <f3_trustees maxOccurs="4"/>
</fields>
let $field_elements :=
  <sequence>
    {
      for $field in $fields/*
        return <element name="{$field}" 
                        type="{if ($field/@type) then $field/@type else "xsd:string"}"
                        minOccurs="{if ($field/@minOccurs) then $field/@minOccurs else "0"}"
                        maxOccurs="{if ($field/@maxOccurs) then $field/@maxOccurs else "1"}"
                        />
    }
  </sequence>
return 
  <schema 
     targetnamespace="http://com.stuarthack.com/schema/Sponsor";>
	<element name="Sponsor">
	   <complexType>
          {$field_elements}
       </complexType>
    </element>
  </schema>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]