schemaLocation attribute dropped after XSL transformation

Discussion in 'XML' started by John, Oct 21, 2003.

  1. John

    John Guest

    I have an input document that contains a large base64 encoded
    document. This document also declares a schema location in the root
    element. I want to write an XSL stylesheet that makes an exact copy
    (including the namespace and schema location) of the input document
    except that it removes the base64 encoding and replaces it with the
    text 'REMOVED'.

    I have a stylesheet that does just that except that it drops the
    schemaLocation attribute. Where that attribute is supposed to be I
    get a ="" which then gives me an error when I parse the result because
    it is not well formed XML.

    I am using Xalan (not sure of the version) on Solaris with Java 1.3.1
    on SunOS 5.8

    Can anyone please tell me what I am doing wrong?

    Thanks much,
    -John

    INPUT DOCUMENT:
    <?xml version="1.0" encoding="UTF-8"?>
    <abc:DocumentInfo xmlns:abc="http://abc.com/schema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://abc.com/schema abc.xsd ">
    <BunchOfElements>....</BunchOfElements>
    <Attachment Encoding="BASE64"
    FileType="PDF">biglongbase64stringgoeshere</Attachment>
    </abc:DocumentInfo>

    XSL STYLESHEET:
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:abc="http://www.abc.com/schema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    version="1.0">
    <xsl:eek:utput indent='yes' encoding='UTF-8' method='xml'/>
    <xsl:template match="/abc:TitleInfo">
    <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    </xsl:template>
    <xsl:template match="Attachment" priority="10">
    <Attachment>
    <xsl:attribute name="Encoding"><xsl:value-of
    select="./@Encoding" /></xsl:attribute>
    <xsl:attribute name="FileType"><xsl:value-of
    select="./@FileType" /></xsl:attribute>
    <xsl:text>REMOVED</xsl:text>
    </Attachment>
    </xsl:template>
    <xsl:template match="@*|node()" priority="1">
    <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    </xsl:template>
    </xsl:stylesheet>

    OUTPUT:
    <?xml version="1.0" encoding="UTF-8"?>
    <abc:DocumentInfo xmlns:abc="http://abc.com/schema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ="">
    <BunchOfElements>....</BunchOfElements>
    <Attachment xmlns:abc="http://www.abc.com/schema" Encoding="BASE64"
    FileType="PDF">REMOVED</Attachment>
    </abc:DocumentInfo>
     
    John, Oct 21, 2003
    #1
    1. Advertising

  2. John

    Bob Foster Guest

    I don't see you are doing anything wrong. Here is what I got running your
    document and stylesheet through Saxon 7.5.2:

    <?xml version="1.0" encoding="UTF-8"?>
    <abc:DocumentInfo xmlns:abc="http://abc.com/schema"
    xsi:schemaLocation="http://abc.com/schema abc.xsd "
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <BunchOfElements>....</BunchOfElements>

    <Attachment Encoding="BASE64" FileType="PDF"
    xmlns:abc="http://www.abc.com/schema">REMOVED</Attachment>
    </abc:DocumentInfo>

    I assume this is pretty much what you expected.

    Bob Foster

    "John" <> wrote in message
    news:...
    > I have an input document that contains a large base64 encoded
    > document. This document also declares a schema location in the root
    > element. I want to write an XSL stylesheet that makes an exact copy
    > (including the namespace and schema location) of the input document
    > except that it removes the base64 encoding and replaces it with the
    > text 'REMOVED'.
    >
    > I have a stylesheet that does just that except that it drops the
    > schemaLocation attribute. Where that attribute is supposed to be I
    > get a ="" which then gives me an error when I parse the result because
    > it is not well formed XML.
    >
    > I am using Xalan (not sure of the version) on Solaris with Java 1.3.1
    > on SunOS 5.8
    >
    > Can anyone please tell me what I am doing wrong?
    >
    > Thanks much,
    > -John
    >
    > INPUT DOCUMENT:
    > <?xml version="1.0" encoding="UTF-8"?>
    > <abc:DocumentInfo xmlns:abc="http://abc.com/schema"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xsi:schemaLocation="http://abc.com/schema abc.xsd ">
    > <BunchOfElements>....</BunchOfElements>
    > <Attachment Encoding="BASE64"
    > FileType="PDF">biglongbase64stringgoeshere</Attachment>
    > </abc:DocumentInfo>
    >
    > XSL STYLESHEET:
    > <?xml version="1.0"?>
    > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    > xmlns:abc="http://www.abc.com/schema"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > version="1.0">
    > <xsl:eek:utput indent='yes' encoding='UTF-8' method='xml'/>
    > <xsl:template match="/abc:TitleInfo">
    > <xsl:copy>
    > <xsl:apply-templates select="@*|node()"/>
    > </xsl:copy>
    > </xsl:template>
    > <xsl:template match="Attachment" priority="10">
    > <Attachment>
    > <xsl:attribute name="Encoding"><xsl:value-of
    > select="./@Encoding" /></xsl:attribute>
    > <xsl:attribute name="FileType"><xsl:value-of
    > select="./@FileType" /></xsl:attribute>
    > <xsl:text>REMOVED</xsl:text>
    > </Attachment>
    > </xsl:template>
    > <xsl:template match="@*|node()" priority="1">
    > <xsl:copy>
    > <xsl:apply-templates select="@*|node()"/>
    > </xsl:copy>
    > </xsl:template>
    > </xsl:stylesheet>
    >
    > OUTPUT:
    > <?xml version="1.0" encoding="UTF-8"?>
    > <abc:DocumentInfo xmlns:abc="http://abc.com/schema"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ="">
    > <BunchOfElements>....</BunchOfElements>
    > <Attachment xmlns:abc="http://www.abc.com/schema" Encoding="BASE64"
    > FileType="PDF">REMOVED</Attachment>
    > </abc:DocumentInfo>
     
    Bob Foster, Oct 22, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ulf Heyder
    Replies:
    0
    Views:
    598
    Ulf Heyder
    Oct 16, 2003
  2. Naresh Agarwal
    Replies:
    1
    Views:
    779
    Christian Ludwig
    Jan 13, 2004
  3. DrTebi
    Replies:
    1
    Views:
    689
    Patrick TJ McPhee
    Jun 27, 2004
  4. Replies:
    0
    Views:
    560
  5. bizt
    Replies:
    2
    Views:
    557
    Joseph J. Kesselman
    Jul 11, 2008
Loading...

Share This Page