Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2005, 03:18 PM
Authorized User
 
Join Date: Jun 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to aowen355
Default Modify XML with XSLT

ok heres my problem
I am using SQLXML accompanied by an XML Schema to automatically create an XML document. The generated XML document has certain code in it that I do not want, so my idea is to pass this code through an XSLT file and snip the unwanted code.

the stylesheet type is xml/xsl, because i still want it to appear as XML, i just want it modified to my own specs

for example the XML file contains a line like this:
<y0:YourName xmlns:y0="http://www.it.ojp.gov/jxdm/3.0">Andrew</y0:YourName>
but i want it to read this after it goes through the XSLT file
<YourName>Andrew</YourName>

so basically I am trying to strip the namespace information. can anyone help me??

 
Old June 29th, 2005, 05:05 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Use:

<xsl:template match="y0:YourName" xmlns:y0="http://www.it.ojp.gov/jxdm/3.0">
  <xsl:element name="local-name()">
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>

probably combined with an identity template so that other elements are copied unchanged.


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 30th, 2005, 06:45 AM
Authorized User
 
Join Date: Jun 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to aowen355
Default

Thank you
I will give this a shot today and let you know how I make out.
I appreciate your help so much. I just began using XML and XSLT very recently and I am still in the learning stages, so when people like you share their knowledge it is a wonderful thing.

Thank you again.:)

 
Old June 30th, 2005, 08:15 AM
Authorized User
 
Join Date: Jun 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to aowen355
Default

I might be going about this the incorrect way...I do not even know if it is possible to do what I am trying...

An XML file is generated based on the SQL query. Once the XML output is created, some parts of code appear that I do not want: <y0:YourName xmlns:y0="http://www.whatever.com">Andrew</y0:YourName> i do not want the namespace info to appear, just <YourName>Andrew</YourName>

I also want the XML file to appear in the browser as XML code, for instance I want to see <YourName>Andrew</YourName>, not just Andrew.
I cannot seem to get templates to work for this...can anyone point me in the right direction?

 
Old December 26th, 2007, 10:19 AM
Registered User
 
Join Date: Dec 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dharmi
Default

Did you get any solution for this query 'coz even I am stuck with a similar issue.

Dharmendra





Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify XSLT mikeymikey XSLT 4 January 5th, 2008 11:21 PM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
XSLT for complicated xml to xml transf. required doug@sirvisetti XSLT 3 June 17th, 2005 04:26 PM
re: modify the column in a xml file ramya General .NET 1 January 20th, 2005 04:50 AM
Javascript and using the XMLDOM to modify xml TheNinthPlayer Javascript 1 January 5th, 2005 05:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.