how to split an input xml after transforming into multiple xml's using one xslt to implement component linking in tridion

StackOverflow https://stackoverflow.com/questions/10991344

  •  13-06-2021
  •  | 
  •  

Question

suppose input xml is as shown

        <Content>
             <ab>xxxx</ab>
             <bc>yyyyyy</bc>
             <ca>uuuuuuu</ca>
         </Content>

after transformation the output xml file is

          <Content>
             <aaa>xxxx</aaa>
             <bbb>yyyyyy</bbb>
             <ccc>uuuuuuu</ccc>
           </Content>

but I want input xml file to be transformed into a source of tridion component such that the resultant file should look like a component having multiple component links as below output xml:

      <Content>
   <A  xlink:href="/webdavURL/message/aaa.xml" ></A>
   <B xlink:href="/webdavURL/message/bbb.xml" ></B>
   <C  xlink:href="/webdavURL/message/ccc.xml" ></C>
      <Content>

where A,B,C are the separate components that are already created from the files that are formed by splitting up the transformed input xml file into multilple xml files.

componenty A's source: file name should be the transformed tag name like aaa.xml

        <Content>
       <aaa>xxxx</aaa>
        </Content>

here 'aaa' is the tagname for the respective 'ab' tag that is transformed from input xml.

componenty B's source:file name should be the transformed tag name like bbb.xml

        <Content>
       <bbb>yyyyyy</bbb>
        </Content>

here 'bbb' is the tagname for the respective 'bc' tag that is transformed from input xml.

component C's source:file name should be the transformed tag name like ccc.xml

        <Content>
       <ccc>uuuuuuu</ccc>
        </Content>

here 'ccc' is the tagname for the respective 'ca' tag that is transformed from input xml.

So I need only single XSLT which converts input xml to tridion component link format and also split each tag in input xml transform it and store it under respective file with file name as transformed tag name.Can somebody help me out.

No correct solution

OTHER TIPS

Your implementation seems to be completely reinventing the wheel - is there a reason you can not use the standard component linking features offered by SDL Tridion? Assuming you have 3 target component with the following URIs:

  1. Target A (tcm:1-1)
  2. Target B (tcm:1-2)
  3. Target C (tcm:1-3)

And you have some source Component XML, in either an RTF field with links to the 3 items or 3 seperate Component Link fields, you will have XML source similar to this:

<Content>
    <aaa xlink:href="tcm:1-1" xlink:title="Target A">Some text</aaa>
    <bbb xlink:href="tcm:1-2" xlink:title="Target B">Some text</bbb>
    <ccc xlink:href="tcm:1-3" xlink:title="Target C">Some text</ccc>
</Content>

Then all your XSLT needs to do is transform the Source XML using a nXSLT Mediatorto the following:

<body>
    <a tridion:href="tcm:1-1" title="Target A">Some text</a>
    <a tridion:href="tcm:1-2" title="Target B">Some text</a>
    <a tridion:href="tcm:1-3" title="Target C">Some text</a>
</body>

Then apply the Default TBB to turn these links into Dynamic Linking references, and when the page is loaded, the links will get resolved to the paths you want.

If that does not help, please consider re-writing your question so that we can understand what you are actually trying to achieve.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top