Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Xpath and XSLT-transformation problem

Thread Tools

Xpath and XSLT-transformation problem

Posts: n/a
Hi All,

Currently I am trying to convert one xml file into another xml file
which having different format than original xml file.

my input xml file is like:

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

<n1:Group REF="SE" ADJ="N"
ABC_I="PROD" ABC_A="N100C0" ABC_IN="1"
<n1:Series FR="M" REF="SE" ADJ="N"
ABC_I="PROD" ABC_A="N100C0" ABC_IN="1"
<n1:Obs TIME_P="199001" OBS_VALUE="101.2"/>
<n1:Obs TIME_P="199002" OBS_VALUE="103.2"/>
<n1:Obs TIME_P="199003" OBS_VALUE="105.2"/>
<n1:Obs TIME_P="199004" OBS_VALUE="107.2"/>


I have to extract the Series element based on the values of ADJ,ABC_A
etc.My intend is more clear from the following xsl file:
The problem is that in xpath expression it doesn't recognizing
namespace elements ie elements prefixed with n1

Please check this and let me know where i am doing wrong.

<xsl:stylesheet version="1.0" xmlnssl="

<xslutput method="xml" encoding="UTF-8" indent="yes"/>

<xslaram name="REF"/>
<xslaram name="ADJ"/>
<xslaram name="ABC_I"/>
<xslaram name="ABC_A"/>
<xslaram name="ABC_IN"/>
<xslaram name="ABC_B_Y"/>

<xsl:template match="/">

<Table language="en">
<Selector type="theme" code="theme1"/>
<Selector type="domain" code="euro"/>
<Selector type="table" code="bp_q"/>

<AxisZ name="REF">
@ADJ=$ADJ and
@ABC_A=$ABC_A and
@ABC_IN=$ABC_I and
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:value-of select="@REF"/>
<AxisY name="STS_INDICATOR">
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:value-of select="@ABC_IN"/>
<AxisX name="time">
<xsl:for-each select="./n1:Obs">
<xsl:element name="Position">
<xsl:attribute name="value">
<xsl:element name="Cell">
<xsl:attribute name="value">


Thanks and Regards,

Reply With Quote
Posts: n/a
On Mar 30, 8:26 am, "Pathik" <(E-Mail Removed)>
> my input xml file is like:


> My intend is more clear from the following xsl file:

You've gotta be kidding. You're using 8 spaces for
indentation and you've obviously never heard of the 78
chars rule. Worse yet, this is a brilliant example of how
NOT to write XSL transformations. The thing is horrible and
you think it makes anything 'more clear'?

> The problem is that in xpath expression it doesn't
> recognizing namespace elements ie elements prefixed with
> n1

Wonderful. What makes you think that?

> <xsl:for-each
> select="MyData/n1ataSet/n1:Series[
> @ADJ=$ADJ and
> @ABC_A=$ABC_A and
> @ABC_IN=$ABC_I and
> @ABC_B_Y=$ABC_B_Y]">

I would strongly recommend learning some basic debugging
techniques. (Hint: there's an error in this bit of code.)

(Note: looking at awful code and pointing straight at the
bug is something I normally charge for on per-hour basis.
You get answers to smart and thought-provoking questions
for free; do not expect people to do your bloody job for
you. Keep that in mind.)

Pavel Lepin

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM