W3C home > Mailing lists > Public > xproc-dev@w3.org > June 2012

AW:Re: Transfer attribute data into a text node (apparently not with p:string-replace)

From: Georges Schmitz <georges.schmitz@arcor.de>
Date: Wed, 27 Jun 2012 07:59:46 +0200
Message-ID: <pea9js858rk01naor9uih638.1340776786549@email.android.com>
To: rdeltour@gmail.com
Cc: xproc-dev@w3.org
Thanks for the answer. I was also thinking of first inserting a dummy node, but that doesn't look like being straightforward to me (and others, I'm supposed to write scripts that my colleagues are able to understand)

I did it in the end with an inline XSLT. 
Georges Romain Deltour <rdeltour@gmail.com> hat geschrieben:I suppose that if the element has no content you can always add a dummy child node with p:insert, then p:string-replace this dummy child with your string value.



On 26 juin 2012, at 18:31, Georges Schmitz wrote:


I wonder if there is an elegant way to get this working on "empty text nodes".

I have to achieve a transfer of attribute data into a text node :
<status value="active"/>  => <status>active</status>

So my approach was to first create the text node and in a second step drop the "value" attribute. But the creation of text nodes already fails with:
<p:string-replace match="*[@value]/node()" replace="parent::*/@value" name="value-attr2textnode"/>

<status value="active"/>

<p:string-replace> doesn't produce anything, you need at least whitepsace in between. 
<status value="active"> </status>
It seems that "string-replace" is interpreted pretty literally; if there is no text node, nothing to replace and it won't be created. 

Should I solve this with a little inline XSLT (which is easy), or can this be done with lean XProc "on-board equipment"?

Thanks for any response,
Received on Wednesday, 27 June 2012 06:00:18 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:17:03 UTC