• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Need help in XML & XSL

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an XML source and from where I fetch one of the element value using XSL file. But the problem I am facing is that, instead of getting only one value from the source XML, I am getting the valus of all the elements in the source XML. If I remove the 'namespace' attribute in the document element of the source XML, I am getting the value correctly. Could someone pls help me why it is happening so?
XML file
<HR>
<?xml version="1.0"?>
<GetArticle xmlns="com:test eveloper"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" version="1.0"
xml:lang="en">
<Control>
<SessionID>WlpaWlpaaMjAwMTE </SessionID>
</Control>

<Request>
<AccessionNoDetails>
<AccessionNo>ppgz000020</AccessionNo>
<Scope>FULL</Scope>
</AccessionNoDetails>
</Request>
</GetArticle>
<HR>
XSL
<HR>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl utput method="html"/>

<xsl:template match="/">
<TABLE BORDER="1">
<TR>
<TD> <I>TEST</I> </TD>
</TR>
<TR>
<TD> <B> ROW 1 </B> </TD>
</TR>
<TR>
<TD> <B> <xsl:apply-templates/></B> </TD>
</TR>
</TABLE>
</xsl:template>

<xsl:template match="GetArticle/Control">
<xsl:value-of select="SessionID"/>
</xsl:template>

<xsl:template match="GetArticle/Request">

</xsl:template>

</xsl:stylesheet>
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fiz,
Let me try to help you. I can see the problem with your XML file and XSL file.

All the elements in your source XML file is in �com:test: developer� namespace. While in your XSL file all the �xsl:template� looking for an element in source document which is not in any anmespace and it does not find any element in source document which is not in any namespace. All the defaults templates will be executed in this case and this is how you are getting all the value.
Once you remove the namespace declaration from source file then all the elements in source XML file do not belongs to any namespace and the templates in XSL documents get executed.

If you do following change in your source XSL file then you will get desired results.

I am assuming that the namespace string in source document is �com:test: developer�, in case if it is different then change it accordingly in above XSL file.
I hope this make things clear to you.
Thanks
[ March 19, 2003: Message edited by: Vivek Saxena ]
 
Md Fizal
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it. Thanks Vivek...
 
reply
    Bookmark Topic Watch Topic
  • New Topic