[oXygen-user] XSLT coping xsi:schemaLocation?

George Cristian Bina
Thu Aug 9 10:29:34 CDT 2007


Dear Timothy,

An XInclude processor is required to add xml:base attributes to the 
included content so that eventual relative references from the included 
content are still properly resolved.
You can suppress this from Options->Preferences -- XML -- XML Parser by 
disabling the "Base URI fixup" from XInclude options but that is not 
recommended.
You can also disable the copying of the xml:base attribute in the output 
from the stylesheet, for instance:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://www.w3.org/1999/XSL/Transform xslt.xsd">

   <x xmlns="test" xml:base="./test"/>

   <xsl:template match="node() | @*">
     <xsl:copy>
       <xsl:apply-templates select="node() | @*"/>
     </xsl:copy>
   </xsl:template>
   <xsl:template match="@xml:base"/>
</xsl:stylesheet>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina - http://aboutxml.blogspot.com/
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Timothy Reaves wrote:
>      Thanks for the quick response!
> 
>      Unfortunately, your example works except for the XInclude included
> content.  When the element is added to the output document, it has an
> attribute:
> 
> xml:base="BPMTemplate.xml"
> 
> and I'm not completely sure where it came from.  In my 'master' document
> the include line is:
> 
>  <xi:include href="BPMTemplate.xml"/>
> 
> so it seems the href is carried through to the xml:base attribte.
> 
>      How can I suppress this?
> 
> 
>> Hi Thimothy,
>>
>> There is nothing special about the xsi:schemaLocation attribute in XSLT.
>> You can copy that to the output as you copy any other attribute. For
>> instance the following stylesheet that contains only the recursive copy
>> template applied on itself passes through the xsi:schemaLocation
>> attribute defined on the stylesheet element:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> version="1.0"
>>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>      xsi:schemaLocation="http://www.w3.org/1999/XSL/Transform xslt.xsd">
>>
>>    <xsl:template match="node() | @*">
>>      <xsl:copy>
>>        <xsl:apply-templates select="node() | @*"/>
>>      </xsl:copy>
>>    </xsl:template>
>> </xsl:stylesheet>
>>
>> Best Regards,
>> George
>> ---------------------------------------------------------------------
>> George Cristian Bina - http://aboutxml.blogspot.com/
>> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
>> http://www.oxygenxml.com
>>
>>
>> Timothy Reaves wrote:
>>>      O.K., I think I'm down to the last issue.  When I run my transform,
>>> my root elements xsi:schemaLocation attribute is not copied over
>>> however.  As I need to process the root elements children, I have to
>>> use copy.
>>>
>>>      I tried  using the same technique I use for other attributes, but I
>>> can't specify an attribute name with xsi: in the name.
>>>
>>>      Anyone know how to get the location to copy over? I still need it
>>> in
>>> place to validate the transformed element.  I'd even settle for being
>>> able to hard-code the value in the XSL file.
>>>
>>>
>>>      Thanks.
>>>
>>> _______________________________________________
>>> oXygen-user mailing list
>>> 
>>> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
>>
> 
> 



More information about the oXygen-user mailing list