Focal Point
rename element in xml
August 20, 2009, 09:29 PM
ray_In_Vancouverrename element in xml
I am looking for a way to rename without using a transform
</Header>
...
...
</Header>
To
</Hdr>
...
</Hdr>
Thanks
IWay SM 5.6, 6.01, 6.1, 6.9, 7.0
EDI, XML, XSD, WF 8.0, DM 77,8.0 asp.net, SQL Server
August 20, 2009, 09:37 PM
WazNot knowing what you can do in iWay, from a text perspective, you could initiate some sort of global change.
In Unix and Windows (if installed), things like the
sed command can do this.
Waz...Prod: | WebFOCUS 7.6.10/8.1.04 | Upgrade: | WebFOCUS 8.2.07 | OS: | Linux |
Outputs: | HTML, PDF, Excel, PPT |
In Focus since 1984 |
Pity the lost knowledge of an old programmer! |
August 20, 2009, 11:06 PM
ray_In_VancouverNeeds to be in Iway process,
thanks
IWay SM 5.6, 6.01, 6.1, 6.9, 7.0
EDI, XML, XSD, WF 8.0, DM 77,8.0 asp.net, SQL Server
August 21, 2009, 07:29 AM
RivoUHi,
I don't know if this is the exactly for you but you might try to define XDXMLExtract Service (com.ibi.agents.XDXMLExtract). It allows you to use XPATH expression to locate your element (for example < Header >) and then to define optional name for the root of the extracted subtree (like < Hdr >)
Otherwise... why not to use transform?
Regards,
Rivo
iSM 6.0
iDM 7.6.5 - 7702
WF 7.6.4 - 7702
All output formats
August 21, 2009, 08:31 AM
TobarRay,
1. Create an XML file listener.
2. Create an XML to XML Transform. Use the file you wish to modify as the input dictionary and data. Use the same file as the output dictionary. Use "Automap" to map the input to Output. In the Output column right click on the "Header" element. Rename it to "Hdr".
3. Create a process flow with your transform followed by a file(write) object.
4. Create your channel using all those elements.
I am not sure of your level of knowledge so I do not know if this is too high level, or too detailed.
Let me know if you have any questions.
------
Livin' down on the cube farm. Left, right, right.
iWay 5.6
Windows
Excel, Tab-delimited, XML
August 21, 2009, 08:58 AM
ray_In_Vancouvercan not use transform. the xml coming in will not always be the same Structure. The only thing that will always be there is the the parent tag </Header> witch needs to get rename because it is now a researved word in Unix.
IWay SM 5.6, 6.01, 6.1, 6.9, 7.0
EDI, XML, XSD, WF 8.0, DM 77,8.0 asp.net, SQL Server
August 21, 2009, 10:25 AM
RivoUIs this < header > root tag for your xml document?
iSM 6.0
iDM 7.6.5 - 7702
WF 7.6.4 - 7702
All output formats
August 21, 2009, 10:33 AM
ray_In_Vancouver<?xml version="1.0"?>
<document>
<header>
</header>
<detail>
</detail>
<detail>
</detail>
<detail>
</detail>
<detail>
</detail>
<footer>
</footer>
</document>
IWay SM 5.6, 6.01, 6.1, 6.9, 7.0
EDI, XML, XSD, WF 8.0, DM 77,8.0 asp.net, SQL Server
August 21, 2009, 11:57 AM
TobarI ay this jokingly, but it is shades of truth. "Your requirements are wrong". Why does it have to be in iWay?
To me it looks like what you are trying to do is better suited to an OS tool instead of a iWay. In my experience iWay does not handle variablity of this sort with ease. I notice your signature says you are in Windows. If you can wait until the file would be on the UNIX platform SED or AWK would be the ticket.
Otherwise maybe RivoU suggestion of XMLXDextract shold be investigated.
------
Livin' down on the cube farm. Left, right, right.
iWay 5.6
Windows
Excel, Tab-delimited, XML
August 21, 2009, 12:04 PM
Michael Darkequote:
exactly for you but you might try to define XDXMLExtract Service (com.ibi.agents.XDXMLExtract). It allows you to use XPATH expression to locate your element (for example < Header >) and
I've used XDXMLExtract before to rename a node. However, I don't think it would work in this case. The service will only bring back the node specified and all child nodes, not sibling nodes. I have an open case on this issue Ray, I'll let you know when I hear back.
Mike.
Vancouver, BC
iWay Adapter Manager version 5.5.005.SP5(i55005SP511) running on Windows platform
iWay Service Manager version 5.6.000.SM running on Windows platform.
August 21, 2009, 12:56 PM
RivoUOK.. maybe not the most elegant solution but does the job...
1) Start
2) Service objects
*Service Object 1:com.ibi.agents.XDXMLExtract
XPath Expression: /document/header/*
Root tag: hdr
*Service Object 2:com.ibi.agents.XDXMLExtract
XPath Expression: //document/detail
Root tag: body
*Service object 3:com.ibi.agents.XDXMLExtract
XPath Expression: /document/footer/
Root tag:
3)Join Object, to merge 3 parts into 1 doc
4) Service object: com.ibi.agents.XDEntagAgent
*Tag Name = document
*Base 64 Encoding = false
5)End
input doc
<?xml version="1.0" encoding="UTF-8" ?>
<document>
<header>
<test1>testhead</test1>
</header>
<detail>
<nr>1</nr>
</detail>
<detail>
<nr>2</nr>
</detail>
<detail>
<nr>3</nr>
</detail>
<detail>
<nr>4</nr>
</detail>
<footer>
<test1>testfoot</test1>
</footer>
</document>
and output:
<?xml version="1.0" encoding="UTF-8" ?>
<document>
<Join joins="3" relations="3">
<body>
<detail>
<nr>1</nr>
</detail>
<detail>
<nr>2</nr>
</detail>
<detail>
<nr>3</nr>
</detail>
<detail>
<nr>4</nr>
</detail>
</body>
<hdr>
<test1>testhead</test1>
</hdr>
<footer>
<test1>testfoot</test1>
</footer>
</Join>
</document>
I try to figure out something better also...
Rivo
iSM 6.0
iDM 7.6.5 - 7702
WF 7.6.4 - 7702
All output formats
August 21, 2009, 02:35 PM
ray_In_Vancouverso close, I get
<?xml version="1.0" encoding="UTF-8" ?>
- <document>
- <Join joins="3" relations="3">
<hdr />
- <body>
- <superroot>
<hdr />
</superroot>
</body>
- <superroot>
- <body>
- <superroot>
<hdr />
</superroot>
</body>
</superroot>
</Join>
</document>
I must be doing something.
IWay SM 5.6, 6.01, 6.1, 6.9, 7.0
EDI, XML, XSD, WF 8.0, DM 77,8.0 asp.net, SQL Server
August 21, 2009, 04:44 PM
ray_In_VancouverSolved
Thanks Rivo
IWay SM 5.6, 6.01, 6.1, 6.9, 7.0
EDI, XML, XSD, WF 8.0, DM 77,8.0 asp.net, SQL Server