[JS][CS4-5] Apply hyperlink to xml tagged object

Hi,
Can anyone please help me? I'm strugling with this problem for days....
I'm trying to apply a new hyperlink to a xml tagged object (piece of text, frame or image)...
The script trows an error "wrong source. Expected text but received XML element"
Does anyone know how i can fix this?
Thanks
Code:
var myDoc = app.documents[0];
Check(myDoc.associatedXMLElement);
alert("Done !");  
//recursive function
function Check(elm){
         for(var i=0; i<elm.xmlElements.length; i++){
               myXMLElement = elm.xmlElements[i];
               XMLelementName = myXMLElement.markupTag.name.toString();
               // only apply to tagged object using the tag "Hyperlink"
               if (XMLelementName == "Hyperlink"){
                      var myHyperlinkURL = myDoc.hyperlinkURLDestinations.add("http://www.google.com");
                      myHyperlinkURL.name = "http://www.google.com";
                      var myObject = elm.parent;
                      if(!( elm.xmlAttributes.item("href") == null)){
                                // it's a picture
                               // i'm not sure this will work
                            myHyperlinkSource = myDoc.hyperlinkPageItemSources.add(myObject);                 
                      }else{
                               // it's not a picture
                              // Error is in the line below
                            myHyperlinkSource = myDoc.hyperlinkTextSources.add(myObject);                 
                      var myHyperlink = myDoc.hyperlinks.add(myHyperlinkSource, myHyperlinkURL);
       // process all sub elements
       for (var i = 0; i < elm.xmlElements.length; i++){
            Check(elm.xmlElements[i]);

Hi,
Thanks for your feedback.
Due to your great feedback, I've made some changes to the line below...
var myObject = elm.texts[0];
When performing the script, a hyperlink is added to all text in the textframe, not only to the text tagged by the xml tag. Does anyone know how this can be fxed?
Also, when trying to do the same thing for  an image, but this doen't work...
var myObject = elm.images[0];
An error occures.
And what about a empty graphic frame ? How can I add a hyperlink to frame if it's tagged by a certain xml tage?
Any feedback would be helpfull...
Tim

Similar Messages

  • [CS5 JS] Problem in Applying character styles xml tag names

    Hi,
    e.g. 1
    <italic>This is a italic text with <sup>superscript value</sup></italic>
    e.g.2
    <sup>This is a superscript text with <bold>Bold superscript</bold></sup>
    <italic>  mapped to character style "italic" and
    <sup> mapped to character style "sup"
    In my java script I already mapped the xml tags to specific character styles. In some of the cases (see e.g.1 and e.g.2) I need to map it to other character styles.
    In e.g.1 I need to apply a new character styles "italicSup" for the text "superscript value" same way
    In e.g.2 I need to apply a new character styles "BoldSup" for the text "Bold superscript".
    Can any know how to do this?
    Green4ever

    FYI, I am using
    Win Xp-SP2, CS5 7.0.3

  • Apply an existing XML Tag To Current Object JS (JavaScript)

    I'm working on a JavaScript to automatically tag the currently-selected object.
    I first check to see if the desired tag already exists -- if not I create it:
              var myXMLElement = myDocument.xmlElements[0].xmlElements.add(tagType);
    Then assign it to the currently-selected object:
              mySelection.markup(myXMLElement);
    This works fine.
    However, if the desired tag ALREADY EXISTS, I'm having problems.  I haven't been able to figure out how to reference the existing element with the markup call.
    Can someone help me with how to do this?
    Thanks much!

    That didn't quite work for me...but it put me in the right direction.  I think I have it working with this snippet:
         myDocument.xmlElements[0].xmlElements.add(tagName, mySelection);
    Thanks much for your help!
    --Aaron

  • XML tag name array

    hi, i want to get an array of tag names
    lets say i have this xml
    <root>
    <bookmeta>
    bunch of xml tags i want to get the name of inside an array
    </boometa>
    </root>
    with this i get an array of xml tag objects
    var myDoc = app.activeDocument;
    var xml = myDoc.xmlElements[0];
    var myNodes = xml.evaluateXPathExpression('//bookmeta/child::node()');
    alert(myNodes);
    if i do .markupTag.name returns undefined,.. Help please!

    done, i created this function and works fine
    function toArray(objects){
                                                var i = objects.length; var array = [];
                                                while(i--){
                                                        array.push(objects[i].markupTag.name);
                                                return array;

  • [CS3][JS] Apply XML tag for selected text

    Hi
      I need to apply XML tag to selected text in a tagged content.The XML tag is already applied for paragraph.I need to apply XML Tag for selected text in a paragraph.
    I have used following code, it applies tag for entire paragraph,not a selected text in a paragraph.
    app.selection[0].associatedXMLElements[0].markupTag=myDoc.xmlTags.item("italic");
    Please suggest me.
    Regards
    kumar

    The example script, markup.jsx
    //Markup.jsx
    //An InDesign CS4 JavaScript
    //Shows how to use the markup method.
    main();
    function main(){
        mySetup();
        mySnippet();
        myTeardown();
    function mySetup(){
        var myDocument = app.documents.add();
        var myPage = app.activeWindow.activePage;
        var myRootXMLElement = myDocument.xmlElements.item(0);
        var myXMLTag = myDocument.xmlTags.add("xml_element");
        var myXMLElementA = myRootXMLElement.xmlElements.add(myXMLTag);
        myXMLElementA.contents = "This is a paragraph in an XML story.";
        var myTextFrame = myPage.textFrames.add({geometricBounds:myGetBounds(myDocument, myPage)});
        myTextFrame.contents = "This is the first paragraph in a text frame.\rThis is the second paragraph in a text frame.\rThis is the third paragraph in a text frame.\rThis is the fourth paragraph in a text frame.\r";
    function mySnippet(){
        //<fragment>
        var myDocument = app.documents.item(0);
        var myPage = myDocument.pages.item(0);
        myDocument.xmlElements.item(0).xmlElements.item(0).markup(myPage.textFrames.item(0));
        //</fragment>
    function myTeardown(){
    function myGetBounds(myDocument, myPage){
        var myPageWidth = myDocument.documentPreferences.pageWidth;
        var myPageHeight = myDocument.documentPreferences.pageHeight
        if(myPage.side == PageSideOptions.leftHand){
            var myX2 = myPage.marginPreferences.left;
            var myX1 = myPage.marginPreferences.right;
        else{
            var myX1 = myPage.marginPreferences.left;
            var myX2 = myPage.marginPreferences.right;
        var myY1 = myPage.marginPreferences.top;
        var myX2 = myPageWidth - myX2;
        var myY2 = myPageHeight - myPage.marginPreferences.bottom;
        return [myY1, myX1, myY2, myX2];
    I think you can use the markup function on the selected item (Text Object have a markup method)
    Thomas B. Nielsen
    http://www.lund-co.dk

  • Add xml Tags in Indesign CS4 by Apple/Java script

    Hi,
    All, I'm new to Indesign Scripting, and I'm hoping someone can help me with the following add xml tags in my xml indesign cs4 files.
    I have IDML (ETMV2) xml Indesign CS4 files. But i have lots of powermath equation without xml tags. So i want how i can insert xml tags.
    My probleam like this =>
    <no open xml tags>[&x^{2}+y_{3}&]<no close xml tags>
    I want like this (But i do manualy)
    <inlineequation><inlinemediaobject><textobject role="xpressmath">[&x^{2}+y_{3}&</textobject></inlinemediaobject></inlineequation>
    Can anyone write/suggest me how i can add xml Tags. By Apple/Java Script
    Any insight is appreciated!
    snegig

    Hi,
    John Hawkinson thank you so much your suggestion.
    I am new  this type of discusion (on this page). So i think anybody could not replay my answer. So i repost my question.
    I want insert tags in my Indesign CS4 files. Is this posible when i select my powermath equaiton then run script. Script add tags automatically before/after my equation. Please ignore IDML word.
    Yes i an comfortable with XSLT presently i working with Pearson ETMV2.
    I have one more question when i past my snapshot its appear properly but when i agin see my commant then my snapshot disappear (see small blue rectangle).
    Thank you John again i am new in this industry please guide.
    snegig

  • Edit JS Script CS4 (Add XML Tags All pages automatically)

    Hi, all Scripter
    I have a javascript for add xml tags (ETMV2 Pearson, InDesign CS4).  We have select my powermath equation data then run script. Script automatically insert xml tags both side (open/close). But we select one by one then run script its time taking.
    var d=app.activeDocument,
    root=d.xmlElements[0],
    ie = root.xmlElements.add("inlineequation", app.selection[0]),
    im = root.xmlElements.add("inlinemediaobject", ie.texts[0]),
    to = root.xmlElements.add("textobject", im.texts[0]);
    to.xmlAttributes.add("role", "xpressmath");
    Example 1: My powermath equation data (InDesign CS4)
    [&x^{2}+y *frac*{1}{2x}&]
    Select powermath equation data then run javascript below mention. Script insert xml tags.
    <inlineequation><inlinemediaobject><textobject>[&x^{2}+y *frac*{1}{2x}&]</inlineequation></inlinemediaobject></textobject>
    Its time taking and select one by one
    Result:
    My main concern is that is this possible script find open [& and close &] all poermath equation data automatically then insert (add) xml tags all pages.
    Thank/Regard
    snegig

    Hi,
    John Hawkinson thank you so much your suggestion.
    I am new  this type of discusion (on this page). So i think anybody could not replay my answer. So i repost my question.
    I want insert tags in my Indesign CS4 files. Is this posible when i select my powermath equaiton then run script. Script add tags automatically before/after my equation. Please ignore IDML word.
    Yes i an comfortable with XSLT presently i working with Pearson ETMV2.
    I have one more question when i past my snapshot its appear properly but when i agin see my commant then my snapshot disappear (see small blue rectangle).
    Thank you John again i am new in this industry please guide.
    snegig

  • How to apply paragraph styles to xml tag?

    Hi All,
    How to apply paragraph style to xml tag?

    Hi Learner,
    Try the below js code.
    var myDoc = app.activeDocument;
    try{
        mySel=app.selection[0];
        myDoc.xmlElements[0].xmlElements.add({markupTag:"TEST", xmlContent:mySel});
        }catch(e){
            alert(e);
    var myDocument = app.activeDocument;
    app.findGrepPreferences.appliedParagraphStyle = "test";
    app.findGrepPreferences.findWhat = ".+(?=\\r)"
    var mySearch = myDocument.findGrep(false);
    for (a=0; a<mySearch.length; a++){
        myDocument.xmlElements[0].xmlElements.add({markupTag:"TEST", xmlContent:mySearch[a]});
    thx,
    csm_phil

  • Find XML Tags then apply para style

    Hi everyone,
    I need your help for find xml tags and apply para graph style in InDesign CS2. We have 200 xml files apply only 7 type of paragraph styles so any one help and any JS/Apply script or any other find and replace method. I am really appreciate of my bottom of heart.
    thank you so much.

    Hi,
    Try:
    #include "../XML Rules/glue code.jsx";
    var myDoc = app.documents.item(0);
    var myRuleSet = new Array (new applyParaStyle());
    with(myDoc){
            var elements = xmlElements;
            __processRuleSet(elements.item(0), myRuleSet);
              function applyParaStyle(){
                        this.name = "Xp";
                        this.xpath = "//restaurant_name";
                        this.apply = function(myElement, myRuleProcessor){
                                  with(myElement){
                    switch(insertionPoints[0].parentTextFrames[0].parentPage.appliedMaster.name){
                        case "X-Master":                   
                        app.select(texts);
                        app.selection[0].fillColor = myDoc.colors.item("xxxx");
                        break;
                        case "guide-Scotland":
                        app.select(texts);
                        app.selection[0].fillColor = myDoc.colors.item("scotland");
                        default:                   
                        break;
                                  return true;

  • [JS] Find & Replace attribute in xml tags (InDesign CS4)

    Hi all,
    Can anyone help me please who i can find and change attribute in xml tags (InDesign CS4) files. I have both link tags but its other attribute different but one attribute same. So who i can change attribute preference.
    (1) one is
    (2) second is
    I want change link preference = 0 but only (2 number,  second) screen shoot. First screen shoot preference = 1 as it is.
    I want this but its manually
    Help me please. Thank you so much adv.
    Regard
    snegig

    Hi John Hawkinson,
    Thank you so much for replay. I am try Jeff, absqua code technique it is simply greet. But my problem is that my both tags link preference = 1 same and other link attribute almost same. So i am unable to change attribute.
    John my code below =>
    var doc = app.activeDocument,
    attNodes = doc.xmlElements[0].evaluateXPathExpression("//link[@preference = '1' or @role = 'generated']"), i, l;
    for (i = 0, l = attNodes.length; i < l; i++) {
    attNodes[i].xmlAttributes.item("preference").remove();
    John please update my code.
    Thank you so much adv.
    Regard
    snegig

  • Does DW cs4 do a good job at collapsing xml tags

    hello;
    I use DW8; I have never been able to get it to collapse xml tags; but now I am doing a lot of xml and it is becoming an issue of effecient workflow;
    does DWcs4 do a good job managing tag-collapse related authoring; for instance, does DWcs4 have something like "collapse all tags" or "cullapse current tag"?
    thanks,
    Shannon

    David,
    I seem to be struggling to "collapse full tag";
    I have tried several scenarios of selecting tags in code view, where an opening tag looks like <blah a="aa" b="bb>:
    - placing my cursor within a tag
    - highlighting a tag's name
    - highlighting all text within a tag
    - highlighting the entire tag
    - highlighting the opening tag all the way to the closing tag
    but each time I get a beep from dreamweaver, implying that I am not doing something right ...
    I would think that this would be a no-brainer, but ...

  • IDOC to File, variable substitution on outbound message XML tag attributes

    My scenario is IDOC to FILE using XSL mappings.The target format is 2 XML tags (header, line) with the data stored in the attributes of each tag.
    EG. <header attr1=one attr2=two attr3=three><line attr1=one attr2=two /></header>
    The name of the file is dictated by an outbound attribute value in the header tag.
    Can I get access to it the attribute in the target message in the CC_FILE using variable substution. ?
    Currently I am not using content conversion as the XSL produces the file format needed, so I would pefer not to change the outbound message format/structure as this is going to an external party. I would prefer not to change the outbound format as this would need content conversion to strip the unwanted/information/processing node that is used for this purpose (file naming).
    The name is a calculation of fields in the IDOC and is not explicit dictated (business logic is applied in the mapping to get the file name), so I would prefer to use the attribute of the resulting XML to keep the "business logic" in the XSL..
    Things that cannot be changed.... 1. Must use XSL.for mapping. 2. Format cannot be changed of the outbound message. 3. Would prefer not to involved content conversion to keep formatting/node structure in the XSL mapping.
    I have seen some reference to this being possible on the forums but nothing solid from what Ive read.
    Something like var1 = payload:/Header/@attr1 in variable sub to get at the attribute
    Any comments ?
    Thanks in advance.
    One final piece of info. its on a PI 7.1 system.

    I think its best explained by my other thread Link:PI 7.1 Access to Dynamic Configuration through Java Class .
    Thanks for the link I have already implemented based on that link but the one crucial difference is that it is implemented using a static method with no reference to the actual object (payload) for Dynamic configuration. It seems that without the 7.0 API which isnt available in 7.1 by default XSL with java extentions is limited to static methods. If you could read the other thread it certainly is possible I'm mistaken.

  • Spec oversight? Using dynamic-attributes in XML tag files

    I have a couple of tagfiles that generate form elements with specific conventions for the 'name' and 'value' attribute. Basically, a data binding framework.
    Dynamic attributes are useful because you can delegate all the usual html attributes to the generated HTML form element: SELECT, INPUT, id, class etc.
    The usual way to do this is to concatenate all the "pass-through" attributes to a string, and append this string to the element generated:
    <input type="hidden" name="foo" ${dynattrs}/>I'm wondering how to do this in a tagfile in XML format (mytag.tagx), since the XML format forbids syntax like in the example above.
    jsp:attribute won't help much, if it's nested inside a c:forEach: it won't apply to the right element.

    Ran into the same problem with 'optional attributes'. (see post "JSP 2.0 Tag files outputting elements with conditional attributes" http://forum.java.sun.com/thread.jspa?forumID=45&threadID=681033)
    Found a solution that is not very elegant but does work and saves you the trouble of reverting to Java Tags. Consider the following tag-file that outputs an html input-tag with conditional attributes:
    <?xml version="1.0" encoding="utf-8"?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"
         xmlns:c="http://java.sun.com/jsp/jstl/core">
         <jsp:directive.attribute name="name" required="true" type="java.lang.String"/>
         <jsp:directive.attribute name="id" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="value" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="disabled" required="false" type="java.lang.Boolean"/>
         <jsp:directive.attribute name="hint" required="false" type="java.lang.String"/>
         <jsp:directive.attribute name="cssClass" required="false" type="java.lang.String"/>
         <jsp:text><![CDATA[<input type="text" name="]]><c:out value="${name}"/><![CDATA["]]></jsp:text>
         <c:if test="${!empty id}"><![CDATA[ id="]]><c:out value="${id}"/><![CDATA["]]></c:if>
         <c:if test="${!empty cssClass}"><![CDATA[ class="]]><c:out value="${disabled?(cssClass + '-disabled'):cssClass}"/><![CDATA["]]></c:if>
         <c:if test="${disabled}"><![CDATA[ disabled="disabled"]]></c:if>
         <c:choose>
              <c:when test="${!empty value}"><![CDATA[ value="]]><c:out value="${value}"/><![CDATA["]]></c:when>
              <c:when test="${!empty hint}"><![CDATA[ value="]]><c:out value="${hint}"/><![CDATA[" onfocus="if(this.value==']]><c:out value="${hint}"/><![CDATA[')this.value='';"]]></c:when>
         </c:choose>
         <jsp:text><![CDATA[/>]]></jsp:text>
    </jsp:root>In answer to your question: Yes, it looks like an oversight. Using the jsp:attribute tag in a c:forEach doesn't work because the attribute is then applied to the forEach tag. You would have to put the attribute-tag inside a jsp:body tag (inside the forEach). Then it would apply not to the forEach tag but to the tag enclosing the forEach. However, this doesn't work either, or at least it doesn't work in Tomcat 5.5. Could be a bug though, JSP 2.0 is still very buggy (for instance, using a tagfile inside another tagfile from the same taglib doesn't seem to work either...)
    Anyway, if you ever find a good solution please let me know by posting to this topic!
    TIA

  • Auto mapping of Columns to custom XML tags

    Hello:
    I would like to build interface to my Oracle database. Instead of exposing the column names, I would like to translate them to business-savvy XML tags. Of course, I can do this by using the AS construct in my SELECT statements.
    I would like to know whether there exists any advanced features in Oracle that automatically do this function.
    Thank you.
    Venkat

    Once you the get the output in xml format from oraext:query-database function you can apply an xsl function to transform it and do the required.

  • How to apply XSLT to XML file while importing XML data using XSU plsql API

    I need to load XML file with nested repeating elements into Oracle tables and I am using XSU PLSQL API utility package dbms_xmlSave.insertXML. Can use XMLGen package also!!
    I found out through documentation that I need to have XML file with ROWSET/ROW tags around the elements. As I have no control of XML file coming from external source, so I wish to apply XSLT to XML. I found setXSLT/setStylesheet procedures but it's not working as expected.
    Can you help me with some sample code for the purpose.
    Thanks

    I'm new at XML and XSL as well, but maybe the following code I built can help:
    CREATE OR REPLACE PACKAGE Xml_Pkg AS
    /* this record and table type are used for the transformTags procedure */
    TYPE TagTransform_t IS RECORD (
    old_tag VARCHAR2(255),
    new_tag VARCHAR2(255) );
    TYPE TagTransformList_t IS TABLE OF TagTransform_t INDEX BY BINARY_INTEGER;
    /* use DBMS_OUTPUT to print out a CLOB */
    PROCEDURE printClobOut(p_clob IN OUT NOCOPY CLOB);
    /* using a list of old/new tags, transform all old into new in XML2 */
    PROCEDURE transformTags(
    p_List TagTransformList_t,
    p_XML1 IN OUT NOCOPY CLOB,
    p_XML2 IN OUT NOCOPY CLOB);
    END Xml_Pkg;
    CREATE OR REPLACE PACKAGE BODY Xml_Pkg AS
    /* print a CLOB using newlines */
    PROCEDURE printClobOut(p_clob IN OUT NOCOPY CLOB) IS
    buffer_overflow EXCEPTION;
    PRAGMA EXCEPTION_INIT(buffer_overflow,-20000);
    l_offset NUMBER;
    l_len NUMBER;
    l_o_buf VARCHAR2(255);
    l_amount NUMBER; --}
    l_f_amt NUMBER := 0; --}To hold the amount of data
    l_f_amt2 NUMBER; --}to be read or that has been
    l_amt2 NUMBER := -1; --}read
    l_offset2 NUMBER;
    l_amt3 NUMBER;
    l_chk NUMBER := 255;
    BEGIN
    l_len := DBMS_LOB.GETLENGTH(p_clob);
    l_offset := 1;
    WHILE l_len > 0 LOOP
    l_amount := DBMS_LOB.INSTR(p_clob,CHR(10),l_offset,1);
    --Amount returned is the count from the start of the file,
    --not from the offset.
    IF l_amount = 0 THEN
    --No more linefeeds so need to read remaining data.
    l_amount := l_len;
    l_amt2 := l_amount;
    ELSE
    l_f_amt2 := l_amount; --Store position of next LF
    l_amount := l_amount - l_f_amt; --Calc position from last LF
    l_f_amt := l_f_amt2; --Store position for next time
    l_amt2 := l_amount - 1; --Read up to but not the LF
    END IF;
    /* divide the read into 255 character chunks for dbms_output */
    IF l_amt2 != 0 THEN
    l_amt3 := l_amt2;
    l_offset2 := l_offset;
    WHILE l_amt3 > l_chk LOOP
    DBMS_LOB.READ(p_clob,l_chk,l_offset2,l_o_buf);
    DBMS_OUTPUT.PUT_LINE(l_o_buf);
    l_amt3 := l_amt3 - l_chk;
    l_offset2 := l_offset2 + l_chk;
    END LOOP;
    IF l_amt3 != 0 THEN
    DBMS_LOB.READ(p_clob,l_amt3,l_offset2,l_o_buf);
    DBMS_OUTPUT.PUT_LINE(l_o_buf);
    END IF;
    END IF;
    l_len := l_len - l_amount;
    l_offset := l_offset+l_amount;
    END LOOP;
    EXCEPTION
    WHEN buffer_overflow THEN
    RETURN;
    END printClobOut;
    /* shortcut "writeline" procedure for CLOB buffer writes */
    PROCEDURE wr(p_clob IN OUT NOCOPY CLOB, s VARCHAR2) IS
    BEGIN
    DBMS_LOB.WRITEAPPEND(p_clob,LENGTH(s)+1,s||CHR(10));
    END;
    /* the standard XSLT should include the identity template or the output XML will be malformed */
    PROCEDURE newXsltHeader(p_xsl IN OUT NOCOPY CLOB, p_identity_template BOOLEAN DEFAULT TRUE) IS
    BEGIN
    DBMS_LOB.TRIM(p_xsl,0);
    /* standard XSL header */
    wr(p_xsl,'<?xml version="1.0"?>');
    /* note that the namespace for the xsl is restricted to the w3 1999/XSL */
    wr(p_xsl,'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">');
    IF p_identity_template THEN
    /* create identity template (transfers all "other" nodes) */
    wr(p_xsl,' <xsl:template match="node()">');
    wr(p_xsl,' <xsl:copy>');
    wr(p_xsl,' <xsl:apply-templates/>');
    wr(p_xsl,' </xsl:copy>');
    wr(p_xsl,' </xsl:template>');
    END IF;
    END newXsltHeader;
    PROCEDURE newXsltFooter(p_xsl IN OUT NOCOPY CLOB) IS
    BEGIN
    /* standard xsl footer */
    wr(p_xsl,'</xsl:stylesheet>');
    END newXsltFooter;
    /* using the stylesheet in p_xsl, transform p_XML1 into p_XML2 */
    PROCEDURE transformXML(p_xsl IN OUT NOCOPY CLOB, p_XML1 IN OUT NOCOPY CLOB, p_XML2 IN OUT NOCOPY CLOB) IS
    l_parser XMLPARSER.Parser;
    l_doc XMLDOM.DOMDocument;
    l_xsl_proc XSLPROCESSOR.Processor;
    l_xsl_ss XSLPROCESSOR.Stylesheet;
    BEGIN
    /* parse XSL CLOB */
    l_parser := XMLPARSER.newParser;
    BEGIN
    XMLPARSER.showWarnings(l_parser,TRUE);
    XMLPARSER.parseClob(l_parser,p_xsl);
    l_doc := XMLPARSER.getDocument(l_parser);
    XMLPARSER.freeParser(l_parser);
    EXCEPTION
    WHEN OTHERS THEN
    XMLPARSER.freeParser(l_parser);
    RAISE;
    END;
    /* get Stylesheet from DOMDOC */
    l_xsl_ss := XSLPROCESSOR.newStylesheet(l_doc,NULL);
    BEGIN
    /* parse XML1 CLOB */
    l_parser := XMLPARSER.newParser;
    BEGIN
    XMLPARSER.showWarnings(l_parser,TRUE);
    XMLPARSER.parseClob(l_parser,p_xml1);
    l_doc := XMLPARSER.getDocument(l_parser);
    XMLPARSER.freeParser(l_parser);
    EXCEPTION
    WHEN OTHERS THEN
    XMLPARSER.freeParser(l_parser);
    RAISE;
    END;
    /* process doc to XML2 */
    l_xsl_proc := XSLPROCESSOR.newProcessor;
    BEGIN
    XSLPROCESSOR.processXSL(l_xsl_proc, l_xsl_ss, l_doc, p_xml2);
    XSLPROCESSOR.freeProcessor(l_xsl_proc);
    EXCEPTION
    WHEN OTHERS THEN
    XSLPROCESSOR.freeProcessor(l_xsl_proc);
    RAISE;
    END;
    XSLPROCESSOR.freeStylesheet(l_xsl_ss);
    EXCEPTION
    WHEN OTHERS THEN
    XSLPROCESSOR.freeStylesheet(l_xsl_ss);
    RAISE;
    END;
    END transformXML;
    /* transform XML1 into XML2 using list p_List of old/new tags */
    PROCEDURE transformTags(p_List TagTransformList_t, p_XML1 IN OUT NOCOPY CLOB, p_XML2 IN OUT NOCOPY CLOB) IS
    l_xsl CLOB;
    BEGIN
    /* create XSL CLOB */
    DBMS_LOB.CREATETEMPORARY(l_xsl,TRUE);
    /* create standard header with identity template */
    newXsltHeader(l_xsl,TRUE);
    /* create one template for each node translation */
    FOR i IN 1..p_List.COUNT LOOP
    wr(l_xsl,' <xsl:template match="'||p_List(i).old_tag||'">');
    wr(l_xsl,' <'||p_List(i).new_tag||'><xsl:apply-templates/></'||p_List(i).new_tag||'>');
    wr(l_xsl,' </xsl:template>');
    END LOOP;
    /* create standard footer */
    newXsltFooter(l_xsl);
    -- dbms_output.put_line('l_xsl:');
    -- dbms_output.put_line('--------------------');
    -- printClobOut(l_xsl);
    -- dbms_output.put_line('--------------------');
    transformXML(l_xsl, p_XML1, p_XML2);
    DBMS_LOB.FREETEMPORARY(l_xsl);
    /* -- unit testing
    set serveroutput on size 100000
    Declare
    queryContext DBMS_XMLQUERY.ctxType;
    xList XML_PKG.TagTransformList_t;
    xmlCLOB CLOB;
    xmlCLOB2 CLOB;
    Begin
    DBMS_LOB.CREATETEMPORARY(xmlCLOB,true);
    DBMS_LOB.CREATETEMPORARY(xmlCLOB2,true);
    xList(1).old_tag := 'A';
    xList(1).new_tag := 'MyTag1';
    xList(2).old_tag := 'B';
    xList(2).new_tag := 'MyTag2';
    queryContext := DBMS_XMLQUERY.newContext('Select * from t');
    xmlCLOB := DBMS_XMLQUERY.getXML(queryContext);
    DBMS_XMLQuery.closeContext(queryContext);
    dbms_output.put_line('xmlCLOB:');
    dbms_output.put_line('--------------------');
    XML_PKG.printClobOut(xmlCLOB);
    dbms_output.put_line('--------------------');
    xml_pkg.transformTags(xList,xmlCLOB,xmlCLOB2);
    dbms_output.put_line('xml2CLOB:');
    dbms_output.put_line('--------------------');
    XML_PKG.printClobOut(xmlCLOB2);
    dbms_output.put_line('--------------------');
    DBMS_LOB.FREETEMPORARY(xmlCLOB);
    DBMS_LOB.FREETEMPORARY(xmlCLOB2);
    End;
    END transformTags;
    END Xml_Pkg;

Maybe you are looking for

  • Outlook Connector - Unable to view messages in IMAP folders

    Hi, I am trying to get the outlook connector (version 7.2.310.1) and it is fine for collecting mail, calenders etc. The problem I am having is with IMAP folders. I have a message rule set up through the webmail view that moves mail with [-SPAM-] in t

  • Not able to edit the words "chapter" and "section" in the document workflow

    Hi all, I would like to point out something that could be a bug. The 2 words "chapter" and "section" are not editable in the document workflow: I can just change the title for each chapter and the title for each section, but I am not able to change t

  • Unable to extract oracle.sar file in Linux

    Hello all, I am aware of installing sap components in windows platform but now as a first time i am installing in linux environment. I am getting issues in oracle installation. First i have installed Red hat linux 5 and started trying to install Orac

  • Automatically watermark all PDFs with Acrobat 9 Pro

    Is it possible to configure Acrobat 9 Pro so that all PDFs incorporate a predetermined watermark?

  • Migrade old NW-cluster to VmWare and iSCSI

    That's the job to be done, question is just; which way to go; Setup today is; 2x Single-CPU XeonServers, both connected to 2xPromise 15HD/Raidkabinetts over 160mb SCSI. This install beeing approx 5 years old and is getting slow and full. Idea is to b