[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using stx:copy

Posted on 2006-05-08
8
Medium Priority
?
438 Views
Last Modified: 2008-02-01
Hey experts,

 I want to use stx right now to copy an xml file as is (later I might remove some nodes), so I am using the following stx code:

<stx:transform       xmlns:stx="http://stx.sourceforge.net/2002/ns"
                xmlns:eteb="http://www.etis.org/EBG/ETEB"
                version="1.0">

  <stx:template match="ediroot">
        <stx:copy attributes="@*">
           <stx:process-children group="COPYALL" />
      </stx:copy>
  </stx:template>
 
  <stx:group name="COPYALL">
    <stx:template match="*">
        <stx:copy attributes="@*">
            <stx:value-of select="."/>
                  <stx:process-children group="COPYALL"/>
            </stx:copy>
    </stx:template>
  </stx:group>

</stx:transform>

Apparently, the code above is not working (it's adding weird nodes that sum the text of two nodes)...any help on the correct syntax to generate a target xml file identical to the source??
0
Comment
Question by:mte01
  • 4
  • 2
  • 2
8 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 16631051
Hey,
I suspect you need something like this

<stx:group name="COPYALL">
    <stx:template match="*">
        <stx:copy>
            <stx:copy-of "@*" />
            <stx:value-of select="."/>
               <stx:process-children group="COPYALL"/>
          </stx:copy>
    </stx:template>
  </stx:group>
0
 
LVL 3

Author Comment

by:mte01
ID: 16631219
>>Gertone

Thanks for your reply, are you sure of the syntax of stx:copy-of (it's giving me a syntax error).....
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 16631317
mte01,
> are you sure of the syntax of stx:copy-of (it's giving me a syntax error)....

you are right, the original was correct, (mixed up with XSLT syntax, sorry)
I will dig deeper, hang on
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Expert Comment

by:jkmyoung
ID: 16631441
Your problem may be with
<stx:value-of select="."/>
<stx:process-children group="COPYALL"/>

Here you handle all the text first, (thus grouping together text nodes)
then deal with the childeren group which only deals with elements

I'm not an expert with stx, but suggest you have something like this where you add an extra template for the text nodes, and remove the text handling inside the element template:

 <stx:group name="COPYALL">
    <stx:template match="*">
        <stx:copy attributes="@*">
               <stx:process-children group="COPYALL"/>
          </stx:copy>
    </stx:template>

    <stx:template match="text()">
    </stx:template>
  </stx:group>

Hope this solves your problem
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 16631450

Do you get duplicates of text?
The <stx:value-of select="."/> looks suspicious to me.
I would expect this to be covered by process-children

maybe you need to have an explicit entry for text nodes in the match of the statement
   <stx:template match="* | text()">
        <stx:copy>
            <stx:copy-of "@*" />
               <stx:process-children group="COPYALL"/>
          </stx:copy>
    </stx:template>

let's see what this brings
0
 
LVL 12

Accepted Solution

by:
jkmyoung earned 690 total points
ID: 16631454
oops, forgot to repaste <stx:value-of> inside the text() template.

<stx:group name="COPYALL">
    <stx:template match="*">
        <stx:copy attributes="@*">
               <stx:process-children group="COPYALL"/>
        </stx:copy>
    </stx:template>

   <stx:template match="text()">
      <stx:value-of select="."/>
   </stx:template>
</stx:group>
0
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 690 total points
ID: 16631474
you might also set the the pass-through attribute to text


<stx:transform      xmlns:stx="http://stx.sourceforge.net/2002/ns"
               pass-through = "text"
                xmlns:eteb="http://www.etis.org/EBG/ETEB"
                version="1.0">
0
 
LVL 3

Author Comment

by:mte01
ID: 16631562
>>Gertone, jkmyoung

Apparently...this was the correct way, after further investigation:

<stx:group name="COPYALL">
    <stx:template match="*">
        <stx:copy attributes="@*">
            <stx:value-of select="."/>
               <stx:process-children group="COPYALL"/>
          </stx:copy>
              <stx:process-siblings group="COPYALL" />
    </stx:template>
  </stx:group>

Many thanks for your help!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Screencast - Getting to Know the Pipeline
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question