Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting schema location

Status
Not open for further replies.

sergivs

Programmer
May 18, 2007
6
US
Hi,

I'm having a little trouble with xsi attributes. I need to convert some XML files from one schema to another. For example, the old file is something like this

<MyRootElement xmlns:xsi=" xsi:noNamespaceSchemaLocation="../../oldschema.xsd">

<OldChild>
.....
</OldChild>
</MyRootElement>


And the new file should be

<MyRootElement xmlns:xsi=" xsi:noNamespaceSchemaLocation="../../newschema.xsd">

<NewChild>
.....
</NewChild>
</MyRootElement>

How can I specify the change from oldschema.xsd to newschema.xsd in my stylesheet?

Thanks in advance.
 
Things are too much accidental of not much general nature. This will do and it contains some generic elements you have to adapt to your concrete case that you "summarized" out. (Note: for those changes and twists you must demonstrate your own initiative!)
[tt]
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" xmlns:xsi="<xsl:eek:utput method="xml" encoding="utf-8" version="1.0" indent="yes" />

<xsl:template match="/">
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="node()|text()|comment()|processing-instruction()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|text()|comment()|processing-instruction()|@*" />
</xsl:copy>
</xsl:template>

<!-- specific templates to override identity transformation -->

<xsl:template match="@*[name()='xsi:noNamespaceSchemaLocation']">
<xsl:copy>
<xsl:value-of select="'../../newschema.xsd'" />
</xsl:copy>
</xsl:template>
<xsl:template match="node()[name()='OldChild']">
<NewChild>
<xsl:apply-templates select="node()|text()|comment()|processing-instruction()|@*" />
</NewChild>
</xsl:template>
</xsl:stylesheet>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top