Action: XSLT Operation on processing-instruction

Post here questions and problems related to oXygen frameworks/document types.
pieterjan_vdw
Posts: 41
Joined: Wed Jun 20, 2018 11:30 am

Action: XSLT Operation on processing-instruction

Post by pieterjan_vdw »

Processing-instructions are visible and editable via custom CSS in my custom framework.

Now I would like to add an action (reply to comments) to a custom toolbar in my custom framework. These comments are stored as processing-instructions.

The is the workflow:
  • I select an existing processing-instruction in author-mode and that processing-instruction has a certain 'attribute' being annotation-id.
    For example

    Code: Select all

    <?annotation-start text="This is an example" annotation-id="a43d6702-5b17-4f11-a4f6-a040df50c88c" author-id="pieterjan.vandenweghe" timestamp=" 1603874838266 "?>
  • In my toolbar, I select the action 'Reply' based on an XSLT operation that creates a new processing-instructions with the annotation-ID added from the processing-instruction selected in step 1. The value of this annotation-ID should in this case be added to the attribute reply-referenceid.
I added an XSLT operation action with below XSLT.
I adds the extra comment but it doesn't copy the annotation-ID of the selected processing-instruction in my new processing instruction.
How can I the copy the 'annotation-id' from my selected 'processing-instruction' into my newly created 'processing instruction'?

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"
	xmlns:saxon="http://saxon.sf.net/" 
	xmlns:oxy="http://www.oxygenxml.com/ns/author/xpath-extension-functions" 
	exclude-result-prefixes="oxy">  
	
	
	<xsl:template match="*">
		<xsl:variable name="annotationid" select="saxon:get-pseudo-attribute('annotation-id')"/>
		<xsl:processing-instruction name="annotation-reply">
            <xsl:text>text="${ask('Enter comment', input_type, '@WKFS: ')}" </xsl:text>
            <xsl:text>annotation-id="${uuid}" </xsl:text>
            <xsl:text>author-id="${author.name}" </xsl:text>
      <xsl:text>reply-referenceid="</xsl:text><xsl:value-of select="$annotationid"/><xsl:text>"</xsl:text>
            <xsl:text>timestamp="</xsl:text>
                                                <xsl:sequence select="
                                                (current-dateTime() - xs:dateTime('1970-01-01T00:00:00'))
                                                div
                                                xs:dayTimeDuration('PT1S') * 1000"/>
                                                <xsl:text>"</xsl:text>
            </xsl:processing-instruction>
	</xsl:template>
</xsl:stylesheet>
Attachments
example.png
example.png (5.52 KiB) Viewed 1210 times
adrian_sorop
Posts: 73
Joined: Wed Jun 22, 2016 2:48 pm

Re: Action: XSLT Operation on processing-instruction

Post by adrian_sorop »

Hi!

By changing template's match to

Code: Select all

processing-instruction()
I was able to properly get the value of the pseudo attribute "annotation-id" with

Code: Select all

saxon:get-pseudo-attribute('annotation-id')
.
With other words, the only change I've made was

Code: Select all

<xsl:template match="processing-instruction()">
and the rest of your xsl remained the same.

Let me know how this works.

Best regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply