cancel
Showing results for 
Search instead for 
Did you mean: 

XML property aliasing with namespace

Former Member
0 Kudos

I have a problem: I receive a XML file in my transaction input

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

<ns0:DATA xmlns:ns0="http://xxx.com/test">

<VALUE_1/>

<VALUE_2/>

</ns0:DATA>

and I maodify it obtaining the following XML file

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

<TAGS>

<VALUE_1/>

<VALUE_2/>

</TAGS>

Does anybody know how to do this?

I tried to use "XSL Transformation" but without results: i receive this error message:

[ERROR]: XSLTransform error: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Il prefisso deve risolvere in namespace: ns0

My XSL file is the following:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<!-- This template copies everything that doesn't have a more specific rule -->

<xsl:template match="node()|@*">

<xsl:copy>

<xsl:apply-templates select="node()|@*"/>

</xsl:copy>

</xsl:template>

<!-- This template copies and renames Books to TechBooks -->

<xsl:template match="ns0:DATA xmlns:ns0=&quot;http://xxx.com/test&quot;">

<TAGS>

<xsl:apply-templates/>

</TAGS>

</xsl:template>

</xsl:stylesheet>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ziofazio,

No need of using XSL transformation

Just use single SQL query in your transaction, it can change your xml file with new tags.

After getting xml file from transaction or input, take repeater to read it and after that add sql query action block.

In that sql query action block, add your query.

code: insert replace('[Param.1]','<ns0:DATA xmlns:ns0="http://xxx.com/test>','<TAGS>') from <DBtablename>

Here Param1 is ur xml file

Hope this is work for your question

Thanks,

Kind Regards,

Praveen Reddy M

Former Member
0 Kudos

I searched in MII help about SQL query on XML files and I found this note:

"For XML queries, you must select XMLConnector as the server"

I don't find "XMLConnector" in "Available servers" list.

Do you know if there is something to enable in order to see this server in the list?

Thank you

Former Member
0 Kudos

Hi ziofazio,

Can you give me few clarification on your question

Exactly from where your XML file is recieving and where you want to save it

Or have you developed any transaction in MII to receive or read xml file from DB or other DB

As i have posted answer based on transaction development which it gets input as XML file

Thanks

Kind Regards,

Praveen Reddy M

Former Member
0 Kudos

Yes, I get it as input XML file.

Sorry, but before I missunderstood and I tried to create a SQL query outside the transaction. Now I inserted it directly in the transaction.

I still have a question:

what do you mean when you say: " take repeater to read it"? I don't know the break condition.

I added a SQL query with the following code:

insert replace(Transaction.Source,'<ns0:DATA xmlns:ns0="http://xxx.com/test>"','<TAGS>') from <DBtablename>

I'm not sure about <DBtablename>, what does this parameter mean?

Are there special rules in SQL query in MII about char " like in string tag? I think no, but I'm not sure

Thank you

Former Member
0 Kudos

Hi,

As you have created sql query for insertion, add this in your transaction

In my point, sql query will have one input parameters

insert replace(replace('[Param.1]','<ns0:DATA xmlns:ns0="http://xxx.com/test>','<TAGS>'),'</ns0:DATA>','</TAGS>')

Then go to transaction and add sql query action block, in that add your sql query through 'configure object'.

In the 'Configure Links' of SQL query map transaction xml input(ie. in your point transaction source) with the 'param.1'

Evaluate it, wether you can able to see that input xml file in that or not.

This will workout.

If not, let me know where your facing problem

Thanks,

kind Regards,

Praveen Reddy M

Former Member
0 Kudos

I tried to do a simpliest thing: I create a new SQL query.

I set its server with a dummy server (that is running) and I set it modes as FixedQuery

I set in parameters tab, Parameter 1 this value:

<?xml version="1.0" encoding="UTF-8"?> <ns0:DATA xmlns:ns0="http://xxx.com/test"> <VALUE_1/> <VALUE_2/> </ns0:DATA>

I set in fixed query details this strings (one for every test):

1 - insert replace(replace('http://Param.1','<ns0:DATA xmlns:ns0="http://xxx.com/test>','<TAGS>'),'</ns0:DATA>','</TAGS>')

2 - insert replace(replace('http://Param.1','<ns0:DATA xmlns:ns0="http://xxx.com/test>"','<TAGS>'),'</ns0:DATA>','</TAGS>')

3 - insert replace(replace('http://Param.1','<ns0:DATA xmlns:ns0=\"http://xxx.com/test>\"','<TAGS>'),'</ns0:DATA>','</TAGS>')

then I run it 3 times with the TestQueryTemplate function (one for every previous string) and everytime I get the same error:

com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '('

Do you have any idea?

Former Member
0 Kudos

Hi,

As you done keep like that only and copy paste this code

select replace(replace('[Param.1]','<ns0:DATA xmlns:ns0="http://xxx.com/test">','<TAGS>'),'</ns0:DATA>','</TAGS>') from dual

And if it successful shows correct then directly copy paste i.e. replace(replace('[Param.1]','<ns0:DATA xmlns:ns0="http://xxx.com/test">','<TAGS>'),'</ns0:DATA>','</TAGS>') this in the position of insert query for param.1

The above code i have tested and its working fine

Thanks,

Kind Regards,

Praveen Reddy M

Former Member
0 Kudos

Thank you, you solved my problem!!

agentry_src
Active Contributor
0 Kudos

I think you guys are overthinking this one.

Build a new transaction. Create a transaction property named InputXML of type xml and a second property named OutputXML of type xml. Put <TAGS /> in OutputXML.

Insert a repeater with the input of

Transaction.InputXML{/ns0:DATA/*}

.

Add an assignment block under the repeater. Assign the repeater output to the OutputXML with Link Type Append XML and the expression Repeater_0.Output{/*} with Target XPath of Transaction.Outputxml{/TAGS}.

I would add a Tracer to display the contents of OutputXML after the repeater completes building it.

Have fun!

Mike

Former Member
0 Kudos

Are you sure about source field in repeater block?

Transaction.InputXML{/ns0:DATA/*} doesn't work. If I evaluate it, I obtain empty value.

I understand your functional idea, but I can't obtain the right Output field in repeater block.

I don't find the right XPath command.

Do you have any idea about it?

Thank you!!

agentry_src
Active Contributor
0 Kudos

Take out the "ns0:" of the xPath. I don't think I had that in my transaction (system is down, so I can't verify that). Not sure why it was included in the code that I pasted into this post, but I obviously missed it when I responded. And I did run my transaction successfully with your input xml.

Regards,

Mike

Former Member
0 Kudos

I think that remove "ns0:" is not the right solution.

With this XML:

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

<ns0:DATA xmlns:ns0="http://xxx.com/test">

<VALUE_1>1</VALUE_1>

<VALUE_2>2</VALUE_2>

</ns0:DATA>

Transaction.Source{count(/ns0:DATA/*)} returns 2

Transaction.Source{count(/DATA/*)} returns 0

Then I think that "ns0:" is necessary.

The problem is to obtain the complete child code:

<VALUE_1>1</VALUE_1>

Do you know which is the XPath code to get the complete child code? I tried @ but it doesn't work

Answers (1)

Answers (1)

Former Member
0 Kudos

Developing a better solution

Former Member
0 Kudos

Sorry: your solution works

Repeater block requires to set XPath command in "Configure Object" tab

Transaction.Source{/ns0:DATA/*} works perfectly.

Thank you a lot!!