OK really simple but I cannot seem to find documentation to get this done...
I want to build the following docuemnt:
<category name="oplages">
<variable name="oplage_aggegated">
<segment name="bruto">2892</segment>
<segment name="stickers">451</segment>
<segment name="netto">2441</segment>
</variable>
</category>
I used "element" before but I need to add attributes now...
This works:
let $ns := "http://www.nvsp.nl/wijk"
let $wijk-bruto := 5
let $wijk-stick := 2
let $wijk-netto := 3
return <wijk id="test" xmlns="http://www.nvsp.nl/wijk">{
element meta-data { comment {"Generated by DIKW for NetwerkVSP STT!P "},
element dateCreated {fn:current-date()}},
element category {
element bruto {$wijk-bruto},
element stickers {$wijk-stick},
element netto {$wijk-netto}
}}
</wijk>
Gives:
<wijk id="test" xmlns="http://www.nvsp.nl/wijk">
<meta-data>
<!--
Generated by DIKW for NetwerkVSP STT!P
-->
<dateCreated>2014-06-06+02:00</dateCreated>
</meta-data>
<category>
<bruto>5</bruto>
<stickers>2</stickers>
<netto>3</netto>
</category>
</wijk>
Now how can I add attributes here?
I feel stupid
tx
hugo
Here is an example:
let $ns := "http://www.nvsp.nl/wijk"
let $wijk-bruto := 5
let $wijk-stick := 2
let $wijk-netto := 3
return
<wijk id="test" xmlns="http://www.nvsp.nl/wijk">
{element category
{attribute
{'Netto' } { $wijk-netto }
}
}
</wijk>
To create the specific document I would use this:
let $ns := "http://www.nvsp.nl/wijk"
let $wijk-bruto := 5
let $wijk-stick := 2
let $wijk-netto := 3
return
<wijk id="test" xmlns="http://www.nvsp.nl/wijk">
<category name="oplages">
<variable name="oplage_aggegated">
<segment>
{attribute { 'name' } { 'bruto' }} {$wijk-bruto}
</segment>
<segment>
{attribute { 'name' } { 'netto' }} {$wijk-netto}
</segment>
<segment>
{attribute { 'name' } { 'stick' }} {$wijk-stick}
</segment>
</variable>
</category>
</wijk>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.