{"id":6634,"date":"2016-07-18T19:41:33","date_gmt":"2016-07-18T17:41:33","guid":{"rendered":"http:\/\/www.b.shuttle.de\/hayek\/hayek\/jochen\/wp\/blog-en\/?p=6634"},"modified":"2016-07-18T19:41:33","modified_gmt":"2016-07-18T17:41:33","slug":"xquery-padding-an-integer-or-a-number-but-not-with-0","status":"publish","type":"post","link":"https:\/\/wp.jochen.hayek.name\/blog-en\/2016\/07\/18\/xquery-padding-an-integer-or-a-number-but-not-with-0\/","title":{"rendered":"XQuery: padding an integer or a number, but not with &#8220;0&#8221;"},"content":{"rendered":"<p>\t\t\t\tI found this function, but it pads on the right:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.xqueryfunctions.com\/xq\/functx_pad-string-to-length.html\">http:\/\/www.xqueryfunctions.com\/xq\/functx_pad-string-to-length.html<\/a>\u00a0:\u00a0functx:pad-string-to-length<\/li>\n<\/ul>\n<p>I derived\u00a0<code>pad-string-to-length-on-the-left<\/code> from it:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/JochenHayek\/misc\/blob\/master\/xqueryfunctions\/pad-string-to-length-on-the-left.xqy\">https:\/\/github.com\/JochenHayek\/misc\/blob\/master\/xqueryfunctions\/pad-string-to-length-on-the-left.xqy<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/JochenHayek\/misc\/blob\/master\/xqueryfunctions\">https:\/\/github.com\/JochenHayek\/misc\/blob\/master\/xqueryfunctions<\/a><\/li>\n<\/ul>\n<p>I use it around format-integer and format-number, e.g.<\/p>\n<pre>let $net_amount_formatted := local:pad-string-to-length-on-the-left( format-number( data($invoice\/@net_amount) , '#,###.#####' ) , ' ' , 12 )<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I found this function, but it pads on the right: http:\/\/www.xqueryfunctions.com\/xq\/functx_pad-string-to-length.html\u00a0:\u00a0functx:pad-string-to-length I derived\u00a0pad-string-to-length-on-the-left from it: https:\/\/github.com\/JochenHayek\/misc\/blob\/master\/xqueryfunctions\/pad-string-to-length-on-the-left.xqy https:\/\/github.com\/JochenHayek\/misc\/blob\/master\/xqueryfunctions I use it around format-integer and format-number, e.g. let $net_amount_formatted := local:pad-string-to-length-on-the-left( format-number( data($invoice\/@net_amount) , &#8216;#,###.#####&#8217; ) , &#8216; &#8216; , 12 )<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false,"_share_on_mastodon":"0"},"categories":[666,732,733],"tags":[],"class_list":["post-6634","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-xpath","category-xquery"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paO0kP-1J0","jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/6634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/comments?post=6634"}],"version-history":[{"count":0,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/6634\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/media?parent=6634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/categories?post=6634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/tags?post=6634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}