cancel
Showing results for 
Search instead for 
Did you mean: 

How to add xmlns attributes in main node

Former Member
0 Kudos

Hi XI Gurus

I'm trying to create an xml output that can be saved as excel (.xls). I started creating the data types but i'm getting an error when I activate the data type. I'm getting the following error:

Name of '/schema/complexType("Workbook")/attribute("xmlns")' starts with 'xml'

Value "xmlns:o" is not allowed for the attribute "name" of type "NCName" in element "/schema/complexType("Workbook")/attribute("xmlns:o")".

Name of '/schema/complexType("Workbook")/attribute("xmlns:o")' starts with 'xml'

Value "xmlns:x" is not allowed for the attribute "name" of type "NCName" in element "/schema/complexType("Workbook")/attribute("xmlns:x")".

Name of '/schema/complexType("Workbook")/attribute("xmlns:x")' starts with 'xml'

Value "xmlns:dt" is not allowed for the attribute "name" of type "NCName" in element "/schema/complexType("Workbook")/attribute("xmlns:dt")".

How can I append the attributes with xmlns in the main node? I tried searching SDN for answers but I can only find steps on how to delete the xmlns part by using XMLBeanalyzer

Thanks!!!

IX

Accepted Solutions (1)

Accepted Solutions (1)

former_member190389
Active Contributor
0 Kudos

Hi,

You Can create a Java Mapping and add the xmlns tag at the desired position using String operations.

for e.g.



String sb = null;
byte[] b = new byte[80000];
int count = 0;
for (int n; (n = inputStream.read(b)) != -1;) 
{
    sb = new String(b, 0, n);
   sb = sb.replaceAll("<MT_test xmlns=\"http://www.w3.org/2001/XMLSchema-instance\" noNamespaceSchemaLocation=\"EDItX_TradeStockReport_V1.1.xsd\" version=\"1.1">","<MT_Test xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"EDItX_TradeStockReport_V1.1.xsd\" version=\"1.1\">");
}

Here I am replacing adding xsi prefix to xmlns attribute.

Likewise you can modify and change it according to your requirement

Former Member
0 Kudos

Thanks Fariha, I will try the UDF that you suggested.

Former Member
0 Kudos

Hi Fariha,

The UDF did not work. I'm getting syntax errors.

cannot find symbol symbol : variable inputStream

cannot find symbol symbol : variable xmlns

Note: /usr/sap/D37/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map4ef021d0147a11df94350025b3237ae8/source/com/sap/xi/tf/_SAPSRMCLMExcel_MM_.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.

Former Member
0 Kudos

Hi Fariha, did you import anything in the JAVA UDF? inputsteam variable cannot be recognized. By input stream did you mean the input variable?

Edited by: Ignatius - Xavier Bazar on Feb 8, 2010 2:48 PM

former_member187339
Active Contributor
0 Kudos

Hi Ignasius,

Fariha is referring to java mapping and not java udf...

Inputstream will not be part of udf..

Also can you paste an example of your source XML structure here.

Regards

Suraj

Former Member
0 Kudos

Hi Suraj,

This is the output that I'm expecting. I'm planning to do an XML based on excel:

<?xml version="1.0" encoding="UTF-8"?>

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"

xmlns:o="urn:schemas-microsoft-com:office:office"

xmlns:x="urn:schemas-microsoft-com:office:excel"

xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"

xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"

xmlns:html="http://www.w3.org/TR/REC-html40"

xmlns:ns0="http://smart.com.ph/SRM_CLM">

<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">

<Version>12.00</Version>

</DocumentProperties>

<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">

<WindowHeight>10005</WindowHeight>

<WindowWidth>10005</WindowWidth>

<WindowTopX>120</WindowTopX>

<WindowTopY>135</WindowTopY>

<ActiveSheet>1</ActiveSheet>

<ProtectStructure>False</ProtectStructure>

<ProtectWindows>False</ProtectWindows>

</ExcelWorkbook>

<Styles>

<Style ss:ID="Default" ss:Name="Normal">

<Alignment ss:Vertical="Bottom"/>

<Borders/>

<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>

<Interior/>

<NumberFormat/>

<Protection/>

</Style>

</Styles>

<Worksheet ss:Name="Configuration">

<Table ss:ExpandedColumnCount="11" ss:ExpandedRowCount="7" x:FullColumns="1"

x:FullRows="1" ss:DefaultRowHeight="15">

<Row>

<Cell ss:MergeAcross="10">

<Data ss:Type="String">ContractsImport Workbook</Data>

</Cell>

</Row>

former_member187339
Active Contributor
0 Kudos

Hi Ignatius,

>>I'm planning to do an XML based on excel:

So are you using any XSD in the target side? I thin rather than making a Data type in PI and then adding the necessary tags, it will be better to create a excel and download the schema of it.

Then you can import it in PI and you will have the necessary tags. I have done a little google and found out this link

http://social.msdn.microsoft.com/forums/en-US/xmlandnetfx/thread/dc51556e-2bfc-444c-9a35-054b5ddd51f...

May be if you try more you will get to know how to make a xsd schema out of an excel sheet. Once it is done import it as an external definition and see whether you get the required XML structure or not

Regards

Suraj

Answers (1)

Answers (1)

former_member200962
Active Contributor
0 Kudos
How can I append the attributes with xmlns in the main node?

Does not seem to be possible.

You can try with one workaround....create a XSD in some tool (like STYLUS or even notepad) and then import it as ED....use it as message type....check if this approach helps.

Regards,

Abhishek.