Altova XMLSpy 2024 Enterprise Edition

Superseded by AuthenticRange.CanPerformActionWith

 

AuthenticRange now supports all functionality of the 'elements' entry helper. Besides querying the elements that can be inserted, appended, etc., you can invoke the action as well. See AuthenticRange.PerformAction for more information.

 

// ----- javascript sample -----

// instead of:

// var arrElements = New Array();

// var objDocEditView = Application.ActiveDocument.DocEditView;

// var objStartElement = objDocEditView.CurrentSelection.Start;

// var objEndElement = objDocEditView.CurrentSelection.End;

// objDocEditView.GetAllowedElements(k_ActionInsertBefore, objStartElement, objEndElement, arrElements);

// use now:

var arrElements = New Array();

Application.ActiveDocument.AuthenticView.Selection.CanPerformActionWith (spyAuthenticInsertBefore, arrElements);

 

Declaration: GetAllowedElements (nAction as SpyAuthenticElementActions, pStartElement as XMLData, pEndElement as XMLData, pElements as Variant)

 

Description

GetAllowedElements() returns the allowed elements for the various actions specified by nAction.

 

JavaScript example:

 

 Function GetAllowed()

 {

         var objView = Application.ActiveDocument.DocEditView;

 

         var arrElements = New Array(1);

 

         var objStart = objView.CurrentSelection.Start;

         var objEnd = objView.CurrentSelection.End;

 

         var strText;

         strText = "valid elements at current selection:\";

 

         For(var i = 1;i <= 4;i++)        {

                 objPlugIn.GetAllowedElements(i,objStart,objEnd,arrElements);

                 strText = strText + ListArray(arrElements) + "------------------\";

         }

 

         Return strText;

 }

 

 Function ListArray(arrIn)

 {

         var strText = "";

 

         If(TypeOf(arrIn) == "object")        {

                 For(var i = 0;i <= (arrIn.length - 1);i++)

                         strText = strText + arrIn[i] + "\";

         }

 

         Return strText;

 }

 

VBScript example:

 

 Sub DisplayAllowed

         Dim objView

         Set objView = Application.ActiveDocument.DocEditView

 

         Dim arrElements()

 

         Dim objStart

         Dim objEnd

         Set objStart = objView.CurrentSelection.Start

         Set objEnd = objView.CurrentSelection.End

 

         Dim strText

         strText = "valid elements at current selection:" & chr(13) & chr(13)

 

         Dim i

 

         For i = 1 To 4

                 objView.GetAllowedElements i,objStart,objEnd,arrElements

                 strText = strText & ListArray(arrElements) & "---------------" & chr(13)

         Next

 

         msgbox strText

 End Sub

 

 Function ListArray(arrIn)

         Dim strText

 

         If IsArray(arrIn) Then

                 Dim i

 

                 For i = 0 To UBound(arrIn)

                         strText = strText & arrIn(i) & chr(13)

                 Next

         End If

 

         ListArray = strText

 End Function

 

 

 

 

© 2017-2023 Altova GmbH