Identifying attributes beeing added as default attributes

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Identifying attributes beeing added as default attributes

Patrik.Stellmann
Hi,

I have quite some use cases where I want to manipulate an xml document with respect to the default attributes but without adding them to the output. Thus, to know the default attributes I have to expand them in the input. But when generating the output I need to identify them to filter them again.

Right now my "solution" is to load the input document again with my own extension function not expanding the default attributes and comparing them. Attributes being present at the input but missing in the additionally loaded documents have to be default attributes. it works but is neither elegant nor has a good performance.

I'd consider it quite simple to add this information as a flag to the attribute item when building the document and have an extension function like saxon:isAddedAsDefaultAttribute to read the flag. Is this possible or exists there already any better solution?

Thanks and regards,

Patrik

GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de

Sitz und Registergericht: Hamburg
HRA 93 894
USt.-IdNr : DE 205183123

Komplementärin:
GDV Beteiligungsgesellschaft mbH
Sitz und Registergericht: Hamburg
HRB 71 153

Geschäftsführer:
Volker Sonnenburg
Heiko Beermann

------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distributionof the material in this e-mail is strictly forbidden.


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Identifying attributes beeing added as default attributes

Imsieke, Gerrit, le-tex
Hi Patrik,

Default attribute expansion may happen with this legacy technology
called “DTD,” right?

You might then consider applying Chris Maloney’s DtdAnalyzer [1] in
order to get an XML representation of the DTD that you can use to
identify the default attribute values in your primary document.

The XML representation looks like this snippet taken from XHTML 1.1:

  <attribute name="shape">
    <attributeDeclaration element="area"
                          type="(rect|circle|poly|default)"
                          defaultValue="rect">
  …

Gerrit

[1] https://github.com/ncbi/DtdAnalyzer


On 19.02.2015 06:26, [hidden email] wrote:

> Hi,
>
> I have quite some use cases where I want to manipulate an xml document
> with respect to the default attributes but without adding them to the
> output. Thus, to know the default attributes I have to expand them in
> the input. But when generating the output I need to identify them to
> filter them again.
>
> Right now my "solution" is to load the input document again with my own
> extension function not expanding the default attributes and comparing
> them. Attributes being present at the input but missing in the
> additionally loaded documents have to be default attributes. it works
> but is neither elegant nor has a good performance.
>
> I'd consider it quite simple to add this information as a flag to the
> attribute item when building the document and have an extension function
> like saxon:isAddedAsDefaultAttribute to read the flag. Is this possible
> or exists there already any better solution?
>
> Thanks and regards,
>
> Patrik
>
> *GDV Dienstleistungs-GmbH & Co. KG*
> Glockengießerwall 1
> D-20095 Hamburg
> www.gdv-dl.de
>
> Sitz und Registergericht: Hamburg
> HRA 93 894
> USt.-IdNr : DE 205183123
>
> Komplementärin:
> GDV Beteiligungsgesellschaft mbH
> Sitz und Registergericht: Hamburg
> HRB 71 153
>
> Geschäftsführer:
> Volker Sonnenburg
> Heiko Beermann
>
> ------------------------------------------------------------------
> Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich
> geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder
> diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
> Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie
> die unbefugte Weitergabe der E-Mail ist nicht gestattet.
>
> This e-mail and any attached files may contain confidential and/or
> privileged information. If you are not the intended recipient (or have
> received this e-mail in error) please notify the sender immediately and
> destroy this e-mail. Any unauthorised copying, disclosure or
> distributionof the material in this e-mail is strictly forbidden.
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>

--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
[hidden email], http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Identifying attributes beeing added as default attributes

Michael Kay
In reply to this post by Patrik.Stellmann
I can see the use case, but unfortunately this information is not in the XDM model. (If it were, it could apply to attributes defaulted from XSD as well as DTD defaults).

Providing extension functions that work on the XDM is easy enough, but defining extensions to the model is difficult.

If the defaults are schema-defined rather than DTD-defined then the Saxon extensions to inspect the schema definitions relating to the type annotation of the node might give you a solution.

Michael Kay
Saxonica
+44 (0) 118 946 5893




On 19 Feb 2015, at 05:26, [hidden email] wrote:

Hi,

I have quite some use cases where I want to manipulate an xml document with respect to the default attributes but without adding them to the output. Thus, to know the default attributes I have to expand them in the input. But when generating the output I need to identify them to filter them again.

Right now my "solution" is to load the input document again with my own extension function not expanding the default attributes and comparing them. Attributes being present at the input but missing in the additionally loaded documents have to be default attributes. it works but is neither elegant nor has a good performance.

I'd consider it quite simple to add this information as a flag to the attribute item when building the document and have an extension function like saxon:isAddedAsDefaultAttribute to read the flag. Is this possible or exists there already any better solution?

Thanks and regards,

Patrik

GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de

Sitz und Registergericht: Hamburg
HRA 93 894
USt.-IdNr : DE 205183123

Komplementärin:
GDV Beteiligungsgesellschaft mbH
Sitz und Registergericht: Hamburg
HRB 71 153

Geschäftsführer:
Volker Sonnenburg
Heiko Beermann

------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distributionof the material in this e-mail is strictly forbidden.


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Identifying attributes beeing added as default attributes

Patrik.Stellmann
In reply to this post by Imsieke, Gerrit, le-tex
Hi Gerrit,

thanks for thi hint. But since I already have xsd rather then dtd, the xml transformation is not necessary. However, interpreting this to find the corresponding attribute declaration considering includes, imports, derivations, type alternatives, overrides, ... would be pretty complex.

Regards

Patrik

------------------------------------------------------------------
Systemarchitektur & IT-Projekte
Tel: +49 40 33449-1142
Fax: +49 40 33449-1400
E-Mail: [hidden email]




Von:        "Imsieke, Gerrit, le-tex" <[hidden email]>
An:        [hidden email],
Datum:        19.02.2015 08:45
Betreff:        Re: [saxon] Identifying attributes beeing added as default        attributes




Hi Patrik,

Default attribute expansion may happen with this legacy technology
called “DTD,” right?

You might then consider applying Chris Maloney’s DtdAnalyzer [1] in
order to get an XML representation of the DTD that you can use to
identify the default attribute values in your primary document.

The XML representation looks like this snippet taken from XHTML 1.1:

 <attribute name="shape">
   <attributeDeclaration element="area"
                         type="(rect|circle|poly|default)"
                         defaultValue="rect">
 …

Gerrit

[1]
https://github.com/ncbi/DtdAnalyzer


On 19.02.2015 06:26, [hidden email] wrote:
> Hi,
>
> I have quite some use cases where I want to manipulate an xml document
> with respect to the default attributes but without adding them to the
> output. Thus, to know the default attributes I have to expand them in
> the input. But when generating the output I need to identify them to
> filter them again.
>
> Right now my "solution" is to load the input document again with my own
> extension function not expanding the default attributes and comparing
> them. Attributes being present at the input but missing in the
> additionally loaded documents have to be default attributes. it works
> but is neither elegant nor has a good performance.
>
> I'd consider it quite simple to add this information as a flag to the
> attribute item when building the document and have an extension function
> like saxon:isAddedAsDefaultAttribute to read the flag. Is this possible
> or exists there already any better solution?
>
> Thanks and regards,
>
> Patrik
>
_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help

GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de

Sitz und Registergericht: Hamburg
HRA 93 894
USt.-IdNr : DE 205183123

Komplementärin:
GDV Beteiligungsgesellschaft mbH
Sitz und Registergericht: Hamburg
HRB 71 153

Geschäftsführer:
Volker Sonnenburg
Heiko Beermann

------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distributionof the material in this e-mail is strictly forbidden.


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Identifying attributes beeing added as default attributes

Michael Kay
In reply to this post by Michael Kay
>
> If the defaults are schema-defined rather than DTD-defined then the Saxon extensions to inspect the schema definitions relating to the type annotation of the node might give you a solution.
>

Since your previous post relates to schema validation, let's try to expand that a little.

We don't have the information that an attribute's value was added by expanding the defaults, but we can test whether the value is equal to the default.

saxon:type(@att) gets you to the type declaration (see http://www.saxonica.com/documentation/#!functions/saxon/type) but unfortunately that isn't very much use, because defaults are defined either on the attribute declaration or the attribute use. To find the attribute use, you would need to use saxon:type($element) on the containing element, then find the {attribute use} components, and from that the attribute declaration: something like

let $t := saxon:type($element)
let $u := $t("attribute uses")[$u("attribute declaration")("name") = $attname]
let $default := $u("value constraint")[.("variety")="default"]("value")

and then you can compare the default value in the schema with the actual value of the attribute.

Michael Kay
Saxonica
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Identifying attributes beeing added as default attributes

Patrik.Stellmann
Thanks for the hint. Now I'm processing my input without expanding the default attributes and use a function to get the default attribute from schema (which works for default as well as for fixed values set on usage and declaration):

    <xsl:function name="gdvdl:GetAttributeDefaultValue" as="xs:string?">
       
<xsl:param name="Element"       as="element()"/>
       
<xsl:param name="AttributeName" as="xs:string"/>
       
       
<xsl:variable name="TypeFct"         as="function(*)"  select="saxon:type($Element)"/>
       
<xsl:variable name="AttributeUseFct" as="function(*)?" select="$TypeFct('attribute uses')[.('attribute declaration')('name') = $AttributeName]"/>
       
<xsl:if test="exists($AttributeUseFct)">
           
<xsl:variable name="UseDefaultFct" as="function(*)?"     select="$AttributeUseFct('value constraint')[.('variety') = ('fixed', 'default')]"/>
           
<xsl:choose>
               
<xsl:when test="exists($UseDefaultFct)">
                   
<xsl:value-of select="$UseDefaultFct('value')"/>
               
</xsl:when>
               
<xsl:otherwise>
                   
<xsl:variable name="AttributeDeclFct"   as="function(*)?" select="$AttributeUseFct('attribute declaration')"/>
                   
<xsl:variable name="DeclDefaultFct"     as="function(*)?" select="$AttributeDeclFct('value constraint')[.('variety') = ('fixed', 'default')]"/>
                   
<xsl:if test="exists($DeclDefaultFct)">
                       
<xsl:value-of select="$DeclDefaultFct('value')"/>
                   
</xsl:if>
               
</xsl:otherwise>
           
</xsl:choose>
       
</xsl:if>
   
</xsl:function>


But now I have to deal with namespaces as well: one relevant attribute is xml:space. It would work with passing "space" as AttributeName but this would not be clean. Thus, I need to get the namespace of the attribute declaration. ('namespace' appears to be no property I can get from the function.)
Could you please point me to some documentation about which properties I can get from which class?

Thanks and regards,


Patrik



Von:        Michael Kay <[hidden email]>
An:        Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>,
Datum:        19.02.2015 11:19
Betreff:        Re: [saxon] Identifying attributes beeing added as default        attributes




>
> If the defaults are schema-defined rather than DTD-defined then the Saxon extensions to inspect the schema definitions relating to the type annotation of the node might give you a solution.
>

Since your previous post relates to schema validation, let's try to expand that a little.

We don't have the information that an attribute's value was added by expanding the defaults, but we can test whether the value is equal to the default.

saxon:type(@att) gets you to the type declaration (see
http://www.saxonica.com/documentation/#!functions/saxon/type) but unfortunately that isn't very much use, because defaults are defined either on the attribute declaration or the attribute use. To find the attribute use, you would need to use saxon:type($element) on the containing element, then find the {attribute use} components, and from that the attribute declaration: something like

let $t := saxon:type($element)
let $u := $t("attribute uses")[$u("attribute declaration")("name") = $attname]
let $default := $u("value constraint")[.("variety")="default"]("value")

and then you can compare the default value in the schema with the actual value of the attribute.

Michael Kay
Saxonica
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help

GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de

Sitz und Registergericht: Hamburg
HRA 93 894
USt.-IdNr : DE 205183123

Komplementärin:
GDV Beteiligungsgesellschaft mbH
Sitz und Registergericht: Hamburg
HRB 71 153

Geschäftsführer:
Volker Sonnenburg
Heiko Beermann

------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distributionof the material in this e-mail is strictly forbidden.


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: Identifying attributes beeing added as default attributes

Michael Kay

Excellent!

The documentation is the XSD spec itself, specifically the sections describing the schema component model


For example, this section


tells you that the namespace of an attribute declaration is held in a property called "target namespace".

Michael Kay
Saxonica
+44 (0) 118 946 5893




On 19 Feb 2015, at 13:43, [hidden email] wrote:

Thanks for the hint. Now I'm processing my input without expanding the default attributes and use a function to get the default attribute from schema (which works for default as well as for fixed values set on usage and declaration):

    <xsl:function name="gdvdl:GetAttributeDefaultValue" as="xs:string?">
       
<xsl:param name="Element"       as="element()"/>
       
<xsl:param name="AttributeName" as="xs:string"/>
       
       
<xsl:variable name="TypeFct"         as="function(*)"  select="saxon:type($Element)"/>
       
<xsl:variable name="AttributeUseFct" as="function(*)?" select="$TypeFct('attribute uses')[.('attribute declaration')('name') = $AttributeName]"/>
       
<xsl:if test="exists($AttributeUseFct)">
           
<xsl:variable name="UseDefaultFct" as="function(*)?"     select="$AttributeUseFct('value constraint')[.('variety') = ('fixed', 'default')]"/>
           
<xsl:choose>
               
<xsl:when test="exists($UseDefaultFct)">
                   
<xsl:value-of select="$UseDefaultFct('value')"/>
               
</xsl:when>
               
<xsl:otherwise>
                   
<xsl:variable name="AttributeDeclFct"   as="function(*)?" select="$AttributeUseFct('attribute declaration')"/>
                   
<xsl:variable name="DeclDefaultFct"     as="function(*)?" select="$AttributeDeclFct('value constraint')[.('variety') = ('fixed', 'default')]"/>
                   
<xsl:if test="exists($DeclDefaultFct)">
                       
<xsl:value-of select="$DeclDefaultFct('value')"/>
                   
</xsl:if>
               
</xsl:otherwise>
           
</xsl:choose>
       
</xsl:if>
   
</xsl:function>


But now I have to deal with namespaces as well: one relevant attribute is xml:space. It would work with passing "space" as AttributeName but this would not be clean. Thus, I need to get the namespace of the attribute declaration. ('namespace' appears to be no property I can get from the function.)
Could you please point me to some documentation about which properties I can get from which class?

Thanks and regards,


Patrik



Von:        Michael Kay <[hidden email]>
An:        Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>,
Datum:        19.02.2015 11:19
Betreff:        Re: [saxon] Identifying attributes beeing added as default        attributes




>
> If the defaults are schema-defined rather than DTD-defined then the Saxon extensions to inspect the schema definitions relating to the type annotation of the node might give you a solution.
>

Since your previous post relates to schema validation, let's try to expand that a little.

We don't have the information that an attribute's value was added by expanding the defaults, but we can test whether the value is equal to the default.

saxon:type(@att) gets you to the type declaration (see
http://www.saxonica.com/documentation/#!functions/saxon/type) but unfortunately that isn't very much use, because defaults are defined either on the attribute declaration or the attribute use. To find the attribute use, you would need to use saxon:type($element) on the containing element, then find the {attribute use} components, and from that the attribute declaration: something like

let $t := saxon:type($element)
let $u := $t("attribute uses")[$u("attribute declaration")("name") = $attname]
let $default := $u("value constraint")[.("variety")="default"]("value")

and then you can compare the default value in the schema with the actual value of the attribute.

Michael Kay
Saxonica
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de

Sitz und Registergericht: Hamburg
HRA 93 894
USt.-IdNr : DE 205183123

Komplementärin:
GDV Beteiligungsgesellschaft mbH
Sitz und Registergericht: Hamburg
HRB 71 153

Geschäftsführer:
Volker Sonnenburg
Heiko Beermann

------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distributionof the material in this e-mail is strictly forbidden.


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Antwort: Re: Identifying attributes beeing added as default attributes

Patrik.Stellmann
Thanks again. Now this works as well.

Regards,

Patrik




Von:        Michael Kay <[hidden email]>
An:        Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>,
Datum:        19.02.2015 15:20
Betreff:        Re: [saxon] Antwort: Re: Identifying attributes beeing added as        default        attributes





Excellent!

The documentation is the XSD spec itself, specifically the sections describing the schema component model

http://www.w3.org/TR/xmlschema11-1

For example, this section

http://www.w3.org/TR/xmlschema11-1/#Attribute_Declaration_details

tells you that the namespace of an attribute declaration is held in a property called "target namespace".

Michael Kay
Saxonica
mike@...
+44 (0) 118 946 5893




On 19 Feb 2015, at 13:43, [hidden email] wrote:

Thanks for the hint. Now I'm processing my input without expanding the default attributes and use a function to get the default attribute from schema (which works for default as well as for fixed values set on usage and declaration):

   <xsl:function
name="gdvdl:GetAttributeDefaultValue" as="xs:string?">
     
<xsl:param name="Element"       as="element()"/>
     
<xsl:param name="AttributeName" as="xs:string"/>
     
     
<xsl:variable name="TypeFct"         as="function(*)"  select="saxon:type($Element)"/>
     
<xsl:variable name="AttributeUseFct" as="function(*)?" select="$TypeFct('attribute uses')[.('attribute declaration')('name') = $AttributeName]"/>
     
<xsl:if test="exists($AttributeUseFct)">
         
<xsl:variable name="UseDefaultFct" as="function(*)?"     select="$AttributeUseFct('value constraint')[.('variety') = ('fixed', 'default')]"/>
         
<xsl:choose>
             
<xsl:when test="exists($UseDefaultFct)">
                 
<xsl:value-of select="$UseDefaultFct('value')"/>
             
</xsl:when>
             
<xsl:otherwise>
                 
<xsl:variable name="AttributeDeclFct"   as="function(*)?" select="$AttributeUseFct('attribute declaration')"/>
                 
<xsl:variable name="DeclDefaultFct"     as="function(*)?" select="$AttributeDeclFct('value constraint')[.('variety') = ('fixed', 'default')]"/>
                 
<xsl:if test="exists($DeclDefaultFct)">
                     
<xsl:value-of select="$DeclDefaultFct('value')"/>
                 
</xsl:if>
             
</xsl:otherwise>
         
</xsl:choose>
     
</xsl:if>
 
</xsl:function>


But now I have to deal with namespaces as well: one relevant attribute is xml:space. It would work with passing "space" as AttributeName but this would not be clean. Thus, I need to get the namespace of the attribute declaration. ('namespace' appears to be no property I can get from the function.)

Could you please point me to some documentation about which properties I can get from which class?


Thanks and regards,


Patrik




Von:        
Michael Kay <mike@...>
An:        
Mailing list for the SAXON XSLT and XQuery processor <[hidden email]>,
Datum:        
19.02.2015 11:19
Betreff:        
Re: [saxon] Identifying attributes beeing added as default        attributes




>
> If the defaults are schema-defined rather than DTD-defined then the Saxon extensions to inspect the schema definitions relating to the type annotation of the node might give you a solution.
>

Since your previous post relates to schema validation, let's try to expand that a little.

We don't have the information that an attribute's value was added by expanding the defaults, but we can test whether the value is equal to the default.

saxon:type(@att) gets you to the type declaration (see
http://www.saxonica.com/documentation/#!functions/saxon/type) but unfortunately that isn't very much use, because defaults are defined either on the attribute declaration or the attribute use. To find the attribute use, you would need to use saxon:type($element) on the containing element, then find the {attribute use} components, and from that the attribute declaration: something like

let $t := saxon:type($element)
let $u := $t("attribute uses")[$u("attribute declaration")("name") = $attname]
let $default := $u("value constraint")[.("variety")="default"]("value")

and then you can compare the default value in the schema with the actual value of the attribute.

Michael Kay
Saxonica

This

GDV Dienstleistungs-GmbH & Co. KG
Glockengießerwall 1
D-20095 Hamburg
www.gdv-dl.de

Sitz und Registergericht: Hamburg
HRA 93 894
USt.-IdNr : DE 205183123

Komplementärin:
GDV Beteiligungsgesellschaft mbH
Sitz und Registergericht: Hamburg
HRB 71 153

Geschäftsführer:
Volker Sonnenburg
Heiko Beermann

------------------------------------------------------------------
Diese E-Mail und alle Anhänge enthalten vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet.

This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distributionof the material in this e-mail is strictly forbidden.


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help