xmlns attribute issue

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

xmlns attribute issue

Saravanan Kuppusamy
Hi,

I am using Saxon9ee.jar in my java application. The process is that, I have master.xml, and whenever a program generates a chunk.xml, I import the chunk.xml in the master.xml using the below XSLT. In this case, master.xml updated by the below XML many times.

<xsl:stylesheet version='3.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template match='node()|@*'><xsl:copy><xsl:apply-templates select='node()|@*'/></xsl:copy></xsl:template>
<xsl:template match='ParagraphStyleRange[(@GridGyoudori="3" and (descendant::Content)]'><xsl:apply-templates select='document(\"chunk.xml\")/section/*'/></xsl:template>
<xsl:template match='MetadataPacketPreference'/><xsl:template match='TinDocumentDataObject'/><xsl:template match='GraphicProxy'/></xsl:stylesheet>

The issue is that, the chunk.xml comes with 
xmlns="http://www.w3.org/1999/xhtml" attribute, unexpectedly, I am not sure how to fix. Once the chunck.xml imported in the master.xml, then any other iteration after some times, the below template does not hook the element due to the xmlns.

<xsl:template match='ParagraphStyleRange[(@GridGyoudori="3" and (descendant::Content)]'><xsl:apply-templates select='document(\"chunk.xml\")/section/*'/></xsl:template>

Please advise how to solve this issue.

Best wishes,
Saravanan
Newgen KnowledgeWorks
Email: [hidden email]
(M) +91 95000 62164 
Web: http://www.newgen.co/
No: 2/579, Singaravelan Street,
Chinna Nellangarai, Chennai – 600041. India.

 


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: xmlns attribute issue

Michael Kay
First: this is an XSLT coding question that has nothing specifically to do with Saxon. I would recommend raising such questions on StackOverflow. There are plenty of XSLT experts there who could answer the question; it doesn't need any particular knowledge of Saxon.

In fact, this question gets asked nearly every day on StackOverflow. One reason people don't find the answer is that they don't use the right terminology. You need to know that the "xmlns attribute" is actually a default namespace declaration. If you search StackOverflow for "XSLT default namespace declaration" you will find hundreds of people asking the same question.

A default namespace declaration puts the elements in the document into a namespace. When searching for elements in a namespace, you need to use a prefixed name, where the prefix is bound to that namespace. For example

<xsl:template match='ParagraphStyleRange[(@GridGyoudori="3" and (descendant::Content)]'>
 
   <xsl:apply-templates select='document(\"chunk.xml\")/h:section/*' xmlns:h="http://www.w3.org/1999/xhtml"/>

</xsl:template>

That's just an example; it would be more usual to declare the prefix on the xsl:stylesheet element.

You can't use XSLT without understanding namespaces, so I would recommend you do some reading.

Michael Kay
Saxonica
+44 (0) 118 946 5893




On 31 Mar 2015, at 01:50, Saravanan Kuppusamy <[hidden email]> wrote:

Hi,

I am using Saxon9ee.jar in my java application. The process is that, I have master.xml, and whenever a program generates a chunk.xml, I import the chunk.xml in the master.xml using the below XSLT. In this case, master.xml updated by the below XML many times.

<xsl:stylesheet version='3.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template match='node()|@*'><xsl:copy><xsl:apply-templates select='node()|@*'/></xsl:copy></xsl:template>
<xsl:template match='ParagraphStyleRange[(@GridGyoudori="3" and (descendant::Content)]'><xsl:apply-templates select='document(\"chunk.xml\")/section/*'/></xsl:template>
<xsl:template match='MetadataPacketPreference'/><xsl:template match='TinDocumentDataObject'/><xsl:template match='GraphicProxy'/></xsl:stylesheet>

The issue is that, the chunk.xml comes with 
xmlns=" attribute, unexpectedly, I am not sure how to fix. Once the chunck.xml imported in the master.xml, then any other iteration after some times, the below template does not hook the element due to the xmlns.

<xsl:template match='ParagraphStyleRange[(@GridGyoudori="3" and (descendant::Content)]'><xsl:apply-templates select='document(\"chunk.xml\")/section/*'/></xsl:template>

Please advise how to solve this issue.

Best wishes,
Saravanan
Newgen KnowledgeWorks
Email: [hidden email]
(M) +91 95000 62164 
Web: http://www.newgen.co/
No: 2/579, Singaravelan Street,
Chinna Nellangarai, Chennai – 600041. India.

 
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help