You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by sh...@e-z.net on 2011/11/08 17:18:12 UTC

Re: Need to copy all elements of a parent element using xalan c++ (1.10)

If you can get a handle to specify properties for the underlying
Xerces XMLReaders, you might try setting the UsingNamespaces to false.
The default for Xalan when creating XMLReaders is "true".

- Steve

>
> The issue may be in the Xerces-C XMLReader when trying to construct a
> nodeset.
> I have not tried such LAX parsing of XML documents with Xerces-C
> callbacks.
>
> When namespace prefixes are used, indicating qualified names, the
> namespaces must be specified.  This is part of wellformedness.  The
> presence of prefixes without qualifying names will cause the nodeset
> generators to fail during namespace resolution, resulting in an empty
> nodeset.
>
> I have tried several methods trying to workaround your absence of
> namespace qualified prefixes and failed.  If you must have this
> capability,
> you may need to coerce your source into a nodeset by other means and
> supply your own document tree walker. - Good Luck!
>
> Maybe someone else can shed some light on how to set specific features
> for XMLReaders to accomplish what you want.
>
> - Steve
>
> On 11/7/2011 5:39 PM, shathawa@e-z.net wrote:
>>> Hi,
>>>
>>> I need to copy all the child elements from the parent element to output
>>> xml using xalan c++  transform method. However, one of the child
>>> element
>>> is prefixed but does not have corresponding namespace.
>>>
>>> What should I do in xslt so that all the children elements of parent
>>> element are copied to output xml file without caring the namespace.
>>> Altova
>>> XMLSpy does that but When I use xalan c++ 1.10 , it does not copy.
>>>
>>> How I can achieve this using xalan c++  1.10 ?
>>>
>>> E.g.
>>> Input XML file
>>> ============
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <SwInt:Request>
>>>                  <SwInt:RequestHeader>
>>>
>>> <SwInt1:Requestor>cn=requestor,o=pimxbebb,o=swift1</SwInt1:Requestor>
>>>
>>> <SwInt:Responder>cn=responder,o=pimxus33,o=swift</SwInt:Responder>
>>>                          <SwInt:RequestRef>xyz</SwInt:RequestRef>
>>>                  </SwInt:RequestHeader>
>>> </SwInt:Request>
>>> XSLT file
>>> ======
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <xsl:stylesheet version="1.0"
>>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>     xmlns:Sw="urn:swift:snl:ns.Sw" xmlns:SwInt="urn:swift:snl:ns.SwInt"
>>> xmlns:SwSec="urn:swift:snl:ns.SwSec">
>>>          <xsl:output method="xml" version="1.0" encoding="UTF-8"
>>> indent="yes"/>
>>>          <xsl:template match="/">
>>>                  <xsl:copy-of
>>> select="/SwInt:Request/SwInt:RequestHeader"/>
>>>          </xsl:template>
>>> </xsl:stylesheet>
>>>
>>> Output Xml comes with
>>> <?xml version="1.0" encoding="UTF-8"?>
>>>
>>> Regards
>>> Ajay
>> All namespace prefixes in your XML file should be namespace qualified.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <SwInt:Request  xmlns:SwInt="urn:swift:snl:ns.SwInt"
>>                  xmlns:SwInt1="urn:swift:snl:ns.SwInt1">
>>   <SwInt:RequestHeader>
>>    <SwInt1:Requestor>cn=requestor,o=pimxbebb,o=swift1</SwInt1:Requestor>
>>    <SwInt:Responder>cn=responder,o=pimxus33,o=swift</SwInt:Responder>
>>    <SwInt:RequestRef>xyz</SwInt:RequestRef>
>>   </SwInt:RequestHeader>
>> </SwInt:Request>
>>
>> The following is an edit of your xslt file
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>      xmlns:SwInt="urn:swift:snl:ns.SwInt"
>>      xmlns:SwInt1="urn:swift:snl:ns.SwInt1">
>>   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
>>       omit-xml-declaration="yes"/>
>>   <xsl:template match="/">
>>       <xsl:copy-of select="/SwInt:Request/SwInt:RequestHeader"/>
>>   </xsl:template>
>> </xsl:stylesheet>
>>
>> Producing the output file
>>
>> <SwInt:RequestHeader xmlns:SwInt="urn:swift:snl:ns.SwInt"
>> xmlns:SwInt1="urn:swift:snl:ns.SwInt1">
>>    <SwInt1:Requestor>cn=requestor,o=pimxbebb,o=swift1</SwInt1:Requestor>
>>    <SwInt:Responder>cn=responder,o=pimxus33,o=swift</SwInt:Responder>
>>    <SwInt:RequestRef>xyz</SwInt:RequestRef>
>>   </SwInt:RequestHeader>
>>
>> I am unclear on what you are actually trying to do:
>>
>> You only need in the stylesheet the prefix declarations used in the
>> stylesheet.  The xml documents need namespace declarations for the
>> prefixes they use.
>>
>> Steven J. Hathaway
>>
>>
>>
>
>