AW: [Xml-compile] error: element `SLAObject' not processed at {http://brixworks02.example.com:8080/API/SOAP/Utils/}getSLASResponse/sla_list

Michael Ludwig m.ludwig at epages.com
Fri Jan 27 10:03:58 GMT 2012


> -----Ursprüngliche Nachricht: Mark Overmeer

> > As long as I've already bought my handbasket and punched my ticket,
> > I'm wondering is there's a place to insert an XSLT in XML::Compile's
> > processing chain?  If I could get my hands on the XML response fresh
> > from the SOAP server, correct it, then XML::Compile would be able to
> > proceed correctly.
> 
> There is no clean hook (yet).  I think the you could do the followin.
> 
> The real code is this:
>   package XML::Compile::SOAP;
>   sub _reader(@) { my $self = shift; $self->{schemas}->reader(@_) }
> 
> Add this to your own progam:  (untested)
> 
>   XML::Compile::SOAP::_reader(@)
>   {   my $process_clean_xml = $self->{schemas}->reader(@_);  # code ref
>       sub {  my $dirty_xml = shift;    # isa XML::LibXML::Document
>              # Use XML::LibXML xslt processor to clean-up
>              # I have no experience with that.

Say you want to filter out stuff from the DOM, or rename stuff.
It's really easy to write, hence the utility:

<xsl:stylesheet version="1.0"
  xmlns:bla="urn:x-bla-blub"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <!-- idiom "copy template" or "identity template" -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <!-- filter out undeclared attributes -->
  <xsl:template match="@mtime | bla:Order/@ctime | bla:Item/@ctime"/>

  <!-- filter out undeclared elements, processing child element nodes -->
  <xsl:template match="bla:UselessWrapper | bla:AnotherOne">
    <xsl:apply-templates select="*"/>
  </xsl:template>

  <!-- rename element -->
  <xsl:template match="bla:BadName">
    <bla:GoodName>
      <xsl:apply-templates select="@*|node()"/>
    </bla:GoodName>
  </xsl:template>

</xsl:stylesheet>

Michael



More information about the Xml-compile mailing list